-->
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.  [ 3 posts ] 
Author Message
 Post subject: replicyte() does create new identifier values
PostPosted: Tue May 10, 2005 5:38 am 
Newbie

Joined: Tue May 10, 2005 5:05 am
Posts: 1
Hi

i try to use the new XML feature to export data stored within my database to be able to import this data in a other database (customer database). I want to do this to provide some initial data needed for my application. However this works fine, if i have only flat tables without any associations. But i recogized problems if i have hierarchical data structures. For example i have user groups within my system and user groups may be subgroups of other user groups.

eg: the structure looks like the following

group 1 (uid=1)
---> group 1.1 (uid=2)
--------> group 1.1.1 (uid=3)
---> group 1.2 (uid=4)
etc.

In this case i export the data the following format using EntityMode.DOM4J. Due to the hierarchical structure, the many to one association between groups and subgroups are not embeded within the parent element (embed-xml=false):

Code:
<group uid = "1">
    <name>group 1</name>
</group>

<group uid = "2"&gt;
    <name>group 1.1</name>
    <parentgroup uid = "1"/>
</group>

<group uid = "3">
    <name>group 1.1.1</name>
    <parentgroup uid = "2"/>
</group>

<group uid = "4">
    <name>group 1</name>
    <parentgroup uid = "1"/>
<group>


If i try to replicate the data from XML into a empty database the group with uid = 1 will be replicated first. Then the group with uid = 2 should be replicated and so on. But this does not work, because the first group gets a new identifier value. This identifier value can be different from the identifier value assigned within the source database because it is not garanteed, that the same identifier will be assigned by the destination database too. In this case the foreign key constraint (parentGroup) for the group with uid = 2 does not hold and a ConstraintViolatedException is thrown by the jdbc driver.


According to the hibernate documentation which says (section 11.9):

Quote:
It is occasionally useful to be able to take a graph of persistent instances and make them persistent in a different datastore, without regenerating identifier values.


it should be no problem because the identifier values are reused, but this does not hold for my experiments, when i am trying to replicate the data in a total empty database.

Does anybody has similar problems and does anybody know how to solve this problem?

i would be very glad if somebody can take me out of the dark ;-)

kind regards
Markus


Top
 Profile  
 
 Post subject: Re: replicyte() does create new identifier values
PostPosted: Tue May 10, 2005 9:08 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
mjesseni wrote:
Hi

i try to use the new XML feature to export data stored within my database to be able to import this data in a other database (customer database). I want to do this to provide some initial data needed for my application. However this works fine, if i have only flat tables without any associations. But i recogized problems if i have hierarchical data structures. For example i have user groups within my system and user groups may be subgroups of other user groups.

eg: the structure looks like the following

group 1 (uid=1)
---> group 1.1 (uid=2)
--------> group 1.1.1 (uid=3)
---> group 1.2 (uid=4)
etc.

In this case i export the data the following format using EntityMode.DOM4J. Due to the hierarchical structure, the many to one association between groups and subgroups are not embeded within the parent element (embed-xml=false):

Code:
<group uid = "1">
    <name>group 1</name>
</group>

<group uid = "2"&gt;
    <name>group 1.1</name>
    <parentgroup uid = "1"/>
</group>

<group uid = "3">
    <name>group 1.1.1</name>
    <parentgroup uid = "2"/>
</group>

<group uid = "4">
    <name>group 1</name>
    <parentgroup uid = "1"/>
<group>


If i try to replicate the data from XML into a empty database the group with uid = 1 will be replicated first. Then the group with uid = 2 should be replicated and so on. But this does not work, because the first group gets a new identifier value. This identifier value can be different from the identifier value assigned within the source database because it is not garanteed, that the same identifier will be assigned by the destination database too. In this case the foreign key constraint (parentGroup) for the group with uid = 2 does not hold and a ConstraintViolatedException is thrown by the jdbc driver.


According to the hibernate documentation which says (section 11.9):

Quote:
It is occasionally useful to be able to take a graph of persistent instances and make them persistent in a different datastore, without regenerating identifier values.


it should be no problem because the identifier values are reused, but this does not hold for my experiments, when i am trying to replicate the data in a total empty database.

Does anybody has similar problems and does anybody know how to solve this problem?

i would be very glad if somebody can take me out of the dark ;-)

kind regards
Markus


I am using this feature without any issues with the ids being changed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 10, 2005 3:59 am 
Newbie

Joined: Tue Sep 21, 2004 5:35 am
Posts: 3
I have a similar problem ... did you understand the problem and/or find a solution?

[/url]


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