-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: one-to-one mapping, more than one entry.
PostPosted: Thu Jun 12, 2008 1:44 pm 
Beginner
Beginner

Joined: Thu Jun 12, 2008 10:48 am
Posts: 24
I have the following three tables which I have mapped 1:1,

DC -<1:1>- SUPPLIER -<1:1>- CUSTOMER

In the db however there CUSTOMER table can have multiple entries for each SUPPLIER. Not ideal, but this is an existing project and I can't change it.
So, In the SUPPLIER mapping file I have the following to map the 1:1 relationship:

Code:
      <one-to-one
         name="customer"
         property-ref="supplierFk"
         class="Customer"
         formula="SELECT s.*
                  FROM CUSTOMER s
                  WHERE last_upd = (SELECT MAX(last_upd)
                                               FROM CUSTOMER
                           WHERE supplier_fk = s.SUPPLIER_FK)"/>


The sql inside the formula removes the duplicate entries by choosing the last_updated entry, making the mapping what I want, 1:1.
(I have tried the SQL "manually" and it works)

This isnt working, I get the following stack trace:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: More than one row with the given identifier was found: 773, for class: uk.co.formfill.nhhdcadmin.domain.Supplier; nested exception is org.hibernate.HibernateException: More than one row with the given identifier was found: 773, for class: uk.domain.Supplier
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:406)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:358)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Any suggestions anyone?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.