-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping - null handle - primitive Datentypen (long)
PostPosted: Wed May 30, 2007 4:10 am 
Newbie

Joined: Tue May 29, 2007 11:56 am
Posts: 1
Hibernate version: 3.2.4.sp1

Mapping documents:
<hibernate-mapping package="invordertool.hibernate">
<class name="Auftrag" table="auftrag">
<id name="id" />
<property name="pers1" type="java.lang.Long" column="pers1" />
<property name="pers2" type="java.lang.Long" column="pers2" />
<property name="pers3" type="java.lang.Long" column="pers3" />
<property name="beguenstigter" type="java.lang.Long" column="beguenstigter" />
<property name="kontoart" column="kontoart" type="java.lang.String" />
<property name="verfuegung" column="verfuegung" type="java.lang.String" />
<property name="xml" column="xml" type="java.lang.String" />
</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of invordertool.hibernate.Auftrag.pers2
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:85)

Name and version of the database you are using:
Postgres 8.2.4


Beim Mapping (load aus der DB) sind einige Werte (Datenfeld: pers2) mit 'null' in der DB hinterlegt. Hibernate wirft die o.g. Exception, obwohl in dem Mapping File die Datentypen explizit definiert sind. Dies Problem tritt nur auf, sofern eine Spalte mit null in der DB hinterlegt ist, alles anderen Datensätze lassen sich problemlos laden. Habe ich für das Mapping noch etwas vergessen, irgendein Property? Im Forum & Google habe ich leider zu diesem Thema nichts gefunden...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 5:04 pm 
Newbie

Joined: Thu May 18, 2006 7:38 am
Posts: 10
Hallo!

Wie ist in deiner Java-Klasse (POJO) "Auftrag" "pers2" definiert?

Als long oder als Long ?

Um mit null-Werten umzugehen zu können benötigst du Long - da long kein Null-Wert halten kann.

private long pers2 = null; //geht nicht
private Long pers2 = null; // geht

Marco


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