Does your table have an auto_increment on the id?  Is that your primary key
or is order_id your primary key?

Ben

On Wed, Sep 21, 2011 at 3:21 AM, juanpastas <[email protected]> wrote:

> Hello,
>
> I have:
>
> Study.java:
> ...
>        private int id;
>        private int orderID;
>        private int status;
>        private int priority;
>        private int performingPhysicianUserId;
> ...
>
> The orderID is an ID of an openmrs order.
>
> I have a formulary (jsp file) and controller ( java file ) that saves/edits
> orders/studies in one request.
>
> The problem is that when I try to update the order/study, it says that
> there
> is already a row in the table 'study' (the one mapped to work with
> Study.java) that has the orderID sent in the POST request (I put order_id
> in
> the table study with UNIQUE index, so it fails, because for some reason
> server is trying to save a new Study and not updating an existing one).
>
> If I delete the index it creates a new study with the same order_id.
>
> in the post controller:
> ....
> protected boolean executeCommand(Order order, Study study,
>                        HttpServletRequest request) {
>                if (!Context.isAuthenticated()) {
>                        return false;
>                }
>
>                OrderService orderService = Context.getOrderService();
>
>                try {
>                        if (request.getParameter("saveOrder") != null) {
>                                orderService.saveOrder(order);
>                                service().saveStudy(study);
>
>
> ...
>
> service() is my module service, and saveStudy(study) is implemented similar
> to the openmrs order:
>
> StudyDAOImpl.java:
>
>        public Study saveStudy(Study s) {
>                sessionFactory.getCurrentSession().saveOrUpdate(s);
>                return s;
>        }
>
> Thanks in advance,
>
> --
> View this message in context:
> http://openmrs-mailing-list-archives.1560443.n2.nabble.com/Update-module-entity-tp6814392p6814392.html
> Sent from the Developers mailing list archive at Nabble.com.
>
> _________________________________________
>
> To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to
> [email protected] with "SIGNOFF openmrs-devel-l" in the  body
> (not the subject) of your e-mail.
>
> [mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]
>

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to 
[email protected] with "SIGNOFF openmrs-devel-l" in the  body (not 
the subject) of your e-mail.

[mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

Reply via email to