-->
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: Generating a specific key
PostPosted: Mon Jan 23, 2012 1:39 pm 
Newbie

Joined: Mon Jan 23, 2012 1:28 pm
Posts: 1
Hello,

Here's an example table that looks like what I'm trying to work with:
Code:
table: parent
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(45) | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+

table: child
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| parent_id | int(11)     | NO   | PRI | NULL    |       |
| id        | int(11)     | NO   | PRI | NULL    |       |
| name      | varchar(45) | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+


As you can see, parent's ID is auto-increment but child's is not... The idea here is that each child would have a key like 1-1, 1-2, 1-3 and 2-1, 2-2, 2-3 and so on...

Is there a way Hibernate can create those keys for me? I'm trying to NOT use auto-increment on child's ID field because I wanna make it "human-readable" like the example above.


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.