-->
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.  [ 7 posts ] 
Author Message
 Post subject: insert multiple object 1 session
PostPosted: Mon May 23, 2005 9:22 am 
Beginner
Beginner

Joined: Thu Sep 16, 2004 4:36 am
Posts: 22
Hey all,


I can't add mapping files here as it's forbidden by the client.

But i can give a general overview

I have class 1 that can contain multiple class B's .

Upon insertion off my first class, i get the NonUniqueObjectException.
And truly if i look into the object i see that the Class A contains 2 classB's but they have the same id.
The id in the mappingfile is specified with sequence (param name="sequence" value="Name_sequence").
How come my class B's don't get the id's incremented?

I'm using a postgresql db.

thank you


Jochen


Top
 Profile  
 
 Post subject: Re: insert multiple object 1 session
PostPosted: Mon May 23, 2005 9:40 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
SeJo wrote:
Hey all,


I can't add mapping files here as it's forbidden by the client.

But i can give a general overview

I have class 1 that can contain multiple class B's .

Upon insertion off my first class, i get the NonUniqueObjectException.
And truly if i look into the object i see that the Class A contains 2 classB's but they have the same id.
The id in the mappingfile is specified with sequence (param name="sequence" value="Name_sequence").
How come my class B's don't get the id's incremented?

I'm using a postgresql db.

thank you


Jochen


What client is forbidding you to include mapping files ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 9:43 am 
Beginner
Beginner

Joined: Thu Sep 16, 2004 4:36 am
Posts: 22
the client i'm trying to implement something for.

I'm a consultant :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 9:44 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
SeJo wrote:
the client i'm trying to implement something for.

I'm a consultant :-)


Create a test case using class A and class B like in your example and remove all package names and anything else that might give away client information and there shouldn't be a problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 9:53 am 
Beginner
Beginner

Joined: Thu Sep 16, 2004 4:36 am
Posts: 22
class A: <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping auto-import="false" >
<class name="A"
table="A"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id
name="idInternal"
column="idInternal"
type="long"
unsaved-value="-1"
>
<generator class="sequence">
<param name="sequence">A_sequence</param></generator>
</id>
<some properties here>
<list
name="BInternal"
table="A_B"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
where="B_index is not null"
>

<key
column="A_id"
>

</key>

<index
column="B_index"
/>

<one-to-many
class="B"
/>
</list>
</class>
</hibernate-mapping>

class B:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
auto-import="false"
>
<class
name="B"
table="B"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id
name="idInternal"
column="idInternal"
type="long"
unsaved-value="-1"
>
<generator class="sequence">
<param name="sequence">B_sequence</param> </generator>

</id>
<some properties here>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 3:08 am 
Beginner
Beginner

Joined: Thu Sep 16, 2004 4:36 am
Posts: 22
Ok why is the childs id not generated?
What i see in my object is that the idInternal is 0 for each child (generated id).
But apparently it doesn't set it automatically upon insertion into the database?

someone a hint?


thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 5:12 am 
Beginner
Beginner

Joined: Thu Sep 16, 2004 4:36 am
Posts: 22
if i check the sql statements, it says directly select nextval ('A_sequence')
and then afterwards i get the NonUniqueObjectException.
shouldn't it also specify this: select nextval ('B_sequence') select nextval ('B_sequence')
as i try to insert one A class containing 2 new B classes

thanks


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