-->
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: NullPointerException in org.hibernate.type.IntegerType.next
PostPosted: Fri May 06, 2005 4:10 pm 
Newbie

Joined: Fri May 06, 2005 3:41 pm
Posts: 1
Location: Cambridge, MA
Hi, I'm having trouble adding a serializable array to my object. For the mapping document below, I get a NullPointerException in org.hibernate.type.IntegerType.next.
However, if I comment out the <property name="messages" .../>, then the object
appears to be persisted correctly (although the messages property is not
saved).

I'm trying to work this down to a test case; does anyone have any ideas?
Note I am using the Derby database, but so far I haven't had any other problems with it.

Hibernate version:
3.0.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="org.gnome.yarrr">

<class name="ClosedComment">
<id name="referenceId" column="closedCommentReferenceId">
<generator class="native"/>
</id>
<version name="version" access="field" unsaved-value="null"/>
<many-to-one name="topic" access="field" column="topicId" not-null="true"/>
<property name="content" access="field" type="serializable" length="32000"/>
<many-to-one name="closer" access="field" class="Person" not-null="true"/>
<property name="openDate" access="field" not-null="true" type="timestamp"/>
<property name="closeDate" access="field" not-null="true" type="timestamp"/>
<property name="messages" lazy="true" access="field" type="serializable" length="32000"/>
<set name="proponents" access="field" cascade="all">
<key column="proponentid"/>
<many-to-many column="proponentpersonid" class="Person"/>
</set>
<set name="authors" access="field" cascade="all">
<key column="authorid"/>
<many-to-many column="authorpersonid" class="Person"/>
</set>
</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
java.lang.NullPointerException
at org.hibernate.type.IntegerType.next(IntegerType.java:57)
at org.hibernate.engine.Versioning.increment(Versioning.java:25)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:261)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at org.gnome.yarrr.HibernateUtil.commitTransaction(HibernateUtil.java:169)
at org.gnome.yarrr.tests.YarrrTests.tearDown(YarrrTests.java:33)


Name and version of the database you are using:
Derby

I'm also including the code for the object in question:


/**
* @author walters
*/
public class ClosedComment extends ReferencableObject implements XmlRpcSerializable {
private Topic topic;
private YarrrMarkup content;
private Person closer;
private Date openDate;
private Date closeDate;
private Set /* Person */ proponents;
private Set /* Person */ authors;
private Integer version;
private SavedMessage[] messages;

protected class SavedMessage implements Serializable {
private static final long serialVersionUID = 1L;
private Date date;
private Person.Ref author;
private YarrrMarkup contents;
private Set /* Person.Ref */ subscribers;
private boolean byMe;

public SavedMessage() {}

public SavedMessage(ChatMessage mesg) {
this.date = mesg.getDate();
this.author = mesg.getAuthor();
this.contents = mesg.getContents();
this.subscribers = new HashSet(mesg.getSubscriberRefs());
this.byMe = mesg.isByMe();
}

public Person.Ref getAuthor() {
return author;
}
public boolean isByMe() {
return byMe;
}
public YarrrMarkup getContents() {
return contents;
}
public Date getDate() {
return date;
}
public Set getSubscribers() {
return subscribers;
}
}

private static Log logger = LogFactory.getLog(ClosedComment.class);

public static Set xmlRpcRemotableMethods = new HashSet();

ClosedComment() {}

public ClosedComment(Topic topic, Person closer, String content, Set /* Person */ authors, Date openDate, List /* ChatMessage */ messages) {
this.openDate = openDate;
this.topic = topic;
this.content = new YarrrMarkup(content);
this.closer = closer;
this.closeDate = new Date();
this.proponents = new HashSet();
this.authors = authors;
setMessages(messages);
HibernateUtil.getSession().save(this);
}

private void setMessages(List /* ChatMessage */ messages) {
this.messages = new SavedMessage[messages.size()];
int i = 0;
Iterator it = messages.iterator();
while (it.hasNext()) {
ChatMessage m = (ChatMessage) it.next();
this.messages[i] = new SavedMessage(m);
i++;
}
}

public List /* SavedMessage */ getMessages() {
if (messages == null)
messages = new SavedMessage[0];
return Arrays.asList(messages);
}


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.