-->
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: NullPointer flushing a one-to-many from nullable column
PostPosted: Thu Feb 09, 2006 5:57 am 
Newbie

Joined: Wed Feb 08, 2006 11:52 am
Posts: 5
Hi all,

my question is: is it possible to have a one-to-many association modeled as a Set property from a nullable column?

Trying to do it, I recieve a NullPointerException from Hibernate 3.0.5 (and 3.1.2) when flushing a new source object.

Here my test case is:

http://forum.hibernate.org/viewtopic.php?t=955282

Where am I wrong?
Thank you very much for your help,

Enri.


Last edited by Enri on Fri Feb 10, 2006 6:45 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 6:40 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
My first guess would be that hibernate is calling attivita.setTipologie(null) at some point. Try changing the implementation of the default set in Attivita to
Code:
private Set tipologie = null;
public Set getTipologie() {
  if (tipologie == null) {
    tipologie = new HashSet();
  }
  return tipologie;
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 4:18 am 
Newbie

Joined: Wed Feb 08, 2006 11:52 am
Posts: 5
Hi tenwit and thank you for your reply.

I have made the change you suggested to me, but the error is still there.

I think Hibernate is trying to get the hashCode of the whole <Tipologia>Collection, calculating it on the value of the column ID_TIPO_ATTIVITA (the tipologia field) on the Attivita entity.
The problem is that ID_TIPO_ATTIVITA is a nullable column and so the NullPointerException. I argued this analyzing the stack trace and with the help of the eclipse debug inside Hibernate source code.

So my question is: is there any way to tell hibernate that my association is an optional association from a nullable column?

Thank you all.

Enrico.


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.