-->
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: Composite ID with one key property generated by a sequence
PostPosted: Tue Mar 01, 2016 3:46 am 
Newbie

Joined: Tue Mar 01, 2016 3:38 am
Posts: 2
Hi Everyone.
I have a table with an ID composed by two columns: a string and an ID. This ID is generated by a sequence defined in the DB (Oracle 11g).
How could I map this scenario in my hbm.xml file?
I've seen that composite-id allows to have more than one key property, but can a single key property be mapped as generated by a sequence?
How does Partial Id Generation work (if it's useful in this case)?
I would appreciate any help.
Thanks
Bye bye
Maurizio


Top
 Profile  
 
 Post subject: Re: Composite ID with one key property generated by a sequence
PostPosted: Tue Mar 01, 2016 4:32 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You could let Oracle assign the ID column upon insert by calling the database sequence.
Hibernate defines the `@Generated` and the new `@ValueGenerationType` for this purpose.

If I were you, I'd migrate from legacy HBM because annotations offer more functionalities.


Top
 Profile  
 
 Post subject: Re: Composite ID with one key property generated by a sequence
PostPosted: Thu Mar 03, 2016 6:04 am 
Newbie

Joined: Tue Mar 01, 2016 3:38 am
Posts: 2
Thanks, I can't move from HBM because of project specifications (sigh!).
I tried to set the key property of my composite id as generated on insert,
but I see that only propertis can be mapped as generated, not the key-property tag.
Why? Where am I wrong?
Could you help me? Should I use something different from composite-id and key-property tags?
Thanks in advance
Maurizio


Top
 Profile  
 
 Post subject: Re: Composite ID with one key property generated by a sequence
PostPosted: Thu Mar 03, 2016 6:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It's been a long time since I used HBM, so I don't know how you could fix it from XML.
The HBM mappings will be deprecated in a future release so, sooner or later, you'll have to migrate to annotation-based mappings.


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.