-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to controll the insert order
PostPosted: Thu Jan 06, 2005 5:10 am 
Newbie

Joined: Thu Jan 06, 2005 5:03 am
Posts: 1
public void testAddChild() {
NodeDAO ndao = new NodeDAO();
Node node = ndao.findByID(5);
Node n1 = new Node("grade 1","grade");
Node n2 = new Node("grade 2","grade");
Node n3 = new Node("grade 3","grade");
node.addChildNode(n1);
node.addChildNode(n2);
node.addChildNode(n3);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
}

mysql> select * from node;
+----+---------+--------+----------------+
| ID | NAME | TYPE | PARENT_NODE_ID |
+----+---------+--------+----------------+
| 5 | myschool| school | NULL |
| 14 | grade 1 | grade | 5 |
| 12 | grade 3 | grade | 5 |
| 13 | grade 2 | grade | 5 |
+----+---------+--------+----------------+

how to controll the order of insert?the result should be :

mysql> select * from node;
+----+---------+--------+----------------+
| ID | NAME | TYPE | PARENT_NODE_ID |
+----+---------+--------+----------------+
| 5 | myscholl| school | NULL |
| 12 | grade 1 | grade | 5 |
| 13 | grade 2 | grade | 5 |
| 14 | grade 3 | grade | 5 |
+----+---------+--------+----------------+


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There is by definition no "order" in a RDBMS table. It is just a collection of tuples. If you want ordering, add a column you use for ordering.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.