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.  [ 4 posts ] 
Author Message
 Post subject: How to use a generator with composite-id ?
PostPosted: Wed Oct 08, 2003 10:16 am 
Newbie

Joined: Wed Oct 08, 2003 9:27 am
Posts: 4
Location: Netherlands
(Please ignore incorrect grammar and typo's, English is not my primary language)

Hi all,

Consider this part of my mapping-file:

Code:
   <class name="AdresModel" table="ADRES">
      <composite-id name="adresnr" class="AdresnrModel">
         <key-property name="adresnr"/>
         <generator class="AdresnrPKGenerator">
            <param name="sequence">SEQ_ADRES</param>
         </generator>
      </composite-id>
      ...
      ...


I have a wrapper (with only one field) for my custom PK, and I want to use a PK-Generator mapped to an oracle sequence with it.

The error I get is this:

Code:
2003-10-08 15:00:33,309 ERROR net.sf.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(20)
org.xml.sax.SAXParseException: Element "composite-id" does not allow "generator" here.
   void org.apache.crimson.parser.Parser2.error(java.lang.String, java.lang.Object[])


The funny thing is, IT WORKS and does perfectly what I want. But, since the SAXParseException is thrown, is causes some worries. If this mapping-file is not allowed, what is the way to achieve this ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 11:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It's quite strange to set a composite id with a unique generated key AND another key. That's probably why it's not authorized by the DTD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 10:53 am 
Newbie

Joined: Mon Nov 10, 2003 5:22 pm
Posts: 3
Ok but,
if i have a composite id and i need to use a PK generator what can i do?

sorry my poor english, regards from spain


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 11:39 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
There's actually a FAQ on this that might help you: http://www.hibernate.org/117.html#A35. I tried it out in a small test and it seemed to work quite smoothly with sequences (I was unable to get it working with identity columns).

_________________
nathan


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

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.