-->
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: many-to-one relationship
PostPosted: Fri Dec 05, 2003 8:46 am 
Newbie

Joined: Fri Oct 17, 2003 5:09 am
Posts: 13
Location: Madrid, Espa
Hello,

what is wrong in this mapping with the <many-to-one>:

<class
name="dao.Direccion"
table="DIRECCIONES"
>
<id
name="direccId"
type="int"
column="DIRECC_ID"
>
<generator class="assigned" />
</id>

<property
name="dirnomvia"
type="java.lang.String"
column="DIRNOMVIA"
length="128"
/>
...
<property
name="dircodpos"
type="java.lang.String"
column="DIRCODPOS"
length="128"
/>

</class>

<class
name="dao.Persona"
table="PERSONAS"
>

<id
name="personId"
type="int"
column="PERSON_ID"
>
<generator class="assigned" />
</id>

<property
name="acronpais"
type="java.lang.String"
column="ACRONPAIS"
length="128"
/>
...
<property
name="fechaltap"
type="java.sql.Date"
column="FECHALTAP"
length="10"
/>

<!-- associations -->
<!-- bi-directional many-to-one association to Direccion -->
<many-to-one
name="direccion" class="dao.Direccion"
not-null="true"
>
<column name="DIRECC_ID" />
</many-to-one>

</class>

i get the exception:

[java] INFO: no JDNI name configured
[java] 05-dic-2003 13:39:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
[java] INFO: Query language substitutions: {}
[java] Hibernate: select PERSONAS.PERSON_ID as PERSON_ID, PERSONAS.CODMUNNAC as CODMUNNAC, PERSONAS.CODNACION as CODNACION, PERSONAS.NUM_IDENT as NUM_IDENT, PERSONAS.HABNUMNIE as HABNUMNIE, PERSONAS.CODPRONAC as CODPRONAC, PERSONAS.FECHNACIM as FECHNACIM, PERSONAS.NOMBREHAB as NOMBREHAB, PERSONAS.APELL1HAB as APELL1HAB, PERSONAS.APELL2HAB as APELL2HAB, PERSONAS.ELSEXOHAB as ELSEXOHAB, PERSONAS.DIG_CONTR as DIG_CONTR, PERSONAS.ACRONPAIS as ACRONPAIS, PERSONAS.FECHALTAP as FECHALTAP, PERSONAS.DIRECC_ID as DIRECC_ID from PERSONAS PERSONAS
[java] Hibernate: select direccio0_.DIRECC_ID as DIRECC_ID, direccio0_.DIRNOMVIA as DIRNOMVIA, direccio0_.DIRBLOQUE as DIRBLOQUE, direccio0_.CALIF_NUM as CALIF_NUM, direccio0_.CALNUMSUP as CALNUMSUP, direccio0_.DIRESCALE as DIRESCALE, direccio0_.DIR_KILOM as DIR_KILOM, direccio0_.DIRNUMERO as DIRNUMERO, direccio0_.NUMEROSUP as NUMEROSUP, direccio0_.DIRPLANTA as DIRPLANTA, direccio0_.DIRPORTAL as DIRPORTAL, direccio0_.DIRPUERTA as DIRPUERTA, direccio0_.DIRTIPVIA as DIRTIPVIA, direccio0_.DIRCODPOS as DIRCODPOS from DIRECCIONES direccio0_ where direccio0_.DIRECC_ID=?
[java] [exception] net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tecsidel.Direccion.?
[java] java.lang.NullPointerException
[java] at com.tecsidel.DireccionMetaClass1.setPropertyValues(<generated>)
[java] at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:162)
[java] at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1961)
[java] at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
[java] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
[java] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
[java] at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
[java] at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
[java] at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757)
[java] at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716)
[java] at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
[java] at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959)
[java] at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
[java] at net.sf.hibernate.loader.Loader.find(Loader.java:620)
[java] at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)
[java] at msyslog.Prueba.main(Prueba.java:76)
[java] rethrown as net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tecsidel.Direccion.?
[java] at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:167)
[java] at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1961)
[java] at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
[java] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
[java] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
[java] at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
[java] at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
[java] at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1757)
[java] at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1716)
[java] at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:62)
[java] at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1959)
[java] at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
[java] at net.sf.hibernate.loader.Loader.find(Loader.java:620)
[java] at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314)
[java] at msyslog.Prueba.main(Prueba.java:76)
[java] Caused by: java.lang.NullPointerException
[java] at com.tecsidel.DireccionMetaClass1.setPropertyValues(<generated>)
[java] at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:162)
[java] ... 17 more
[java] Exception in thread "main"

if i delete de <many-to-one> relationship works.

thank in advance.
C


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 9:25 am 
Newbie

Joined: Fri Oct 17, 2003 5:09 am
Posts: 13
Location: Madrid, Espa
well, i read the javadocs and the problem was:
a nullable database column was mapped to a primitive-type property

Un saludo,
C


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.