-->
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.  [ 5 posts ] 
Author Message
 Post subject: One to many association is failing...please help
PostPosted: Sat Nov 26, 2011 5:49 am 
Newbie

Joined: Sat Nov 26, 2011 5:46 am
Posts: 5
java.sql.BatchUpdateException: Batch entry 0 insert into kv.KV_USER_ATTRIBUTES (TYPE, VALUE, NAME, USERID) values ('java.lang.String', '<stream of 11 bytes>', 'attribute1', NULL) was aborted. Call getNextException to see the cause.


Top
 Profile  
 
 Post subject: Re: One to many association is failing...please help
PostPosted: Sat Nov 26, 2011 5:50 am 
Newbie

Joined: Sat Nov 26, 2011 5:46 am
Posts: 5
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Nov 7, 2011 11:55:23 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping auto-import="false">
<class name="com.nd.core.users.User" discriminator-value="User" lazy="false">
<id name="ID" type="java.lang.Long">
<column name="ID" />
<generator class="native"></generator>
</id>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="firstName" type="java.lang.String">
<column name="FIRSTNAME" />
</property>
<property name="lastName" type="java.lang.String">
<column name="LASTNAME" />
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" />
</property>
<property name="markedAsDeleted" type="java.lang.Boolean">
<column name="MARKED_AS_DELETED"/>
</property>
<list name="roles" inverse="true" table="KV_ROLES" lazy="true" cascade="all">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="com.nd.core.users.Role" />
</list>
<set name="attributes" table="KV_USER_ATTRIBUTES" lazy="true" inverse="false" cascade="all">
<key>
<column name="USERID" />
</key>
<one-to-many class="com.nd.core.users.UserAttribute" />
</set>
<union-subclass name="com.nd.core.users.impl.UserImpl" table="KV_USERS"></union-subclass>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: One to many association is failing...please help
PostPosted: Sat Nov 26, 2011 5:51 am 
Newbie

Joined: Sat Nov 26, 2011 5:46 am
Posts: 5
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Nov 8, 2011 12:39:38 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping auto-import="false">
<class name="com.nd.core.users.UserAttribute" abstract="true" >
<composite-id>
<key-property name="name" column="NAME"></key-property>
<key-property name="userID" column="USERID"></key-property>
</composite-id>
<property name="type" type="java.lang.String">
<column name="TYPE" />
</property>
<property name="value" type="java.io.Serializable">
<column name="VALUE" />
</property>
<union-subclass name="com.nd.core.users.impl.UserAttributeImpl" table="KV_USER_ATTRIBUTES">
</union-subclass>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: One to many association is failing...please help
PostPosted: Sat Nov 26, 2011 5:51 am 
Newbie

Joined: Sat Nov 26, 2011 5:46 am
Posts: 5
User user = new UserImpl();
user.setFirstName("John");
user.setLastName("Doe");
user.setEmail("nirmeshd@yahoo.com");

UserAttribute userAttribute = new UserAttributeImpl();
userAttribute.setName("attribute1");
userAttribute.setValue("test");

UserAttribute userAttribute2 = new UserAttributeImpl();
userAttribute2.setName("attribute2");
userAttribute2.setValue("test2");

Set< UserAttribute> userAttributes = new HashSet<UserAttribute>();

userAttributes.add(userAttribute);
userAttributes.add(userAttribute2);

user.setAttributes(userAttributes);

Long _insertedUserID = um.insertUser(user);

assertTrue("null user id returned",_insertedUserID != null);

User userFound = um.getUser(_insertedUserID);

assertTrue("user not found after insert",userFound != null);


Top
 Profile  
 
 Post subject: Re: One to many association is failing...please help
PostPosted: Sun Nov 27, 2011 3:07 pm 
Newbie

Joined: Wed Jun 01, 2011 1:16 am
Posts: 4
kni wrote:
Call getNextException to see the cause.


Might be helpful to see the whole stack trace.

Also, what is "um"? UserManager? How is it implemented?

kni wrote:
um.insertUser...


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