-->
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: 1-1 relation -> "Could not find a setter for propert
PostPosted: Wed Apr 26, 2006 5:57 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
Hi, i'm having problem creating a 1-1 relation. 1-N works fine, but when I try to do 1-1 it complains about not finding a setter. So weird!

Im using NetBeans 5.0 with the hibernate plugin.
All code below is auto generated by the plugin.


Hibernate version:
3.1.3
Mapping documents:

Kossa.hbm.xml:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="javaapplication3.Kossa"
table="KOSSA"
>

<id
name="id"
column="id"
type="java.lang.String"
>
<generator class="uuid.hex">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Kossa.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<one-to-one
name="apa"
class="javaapplication3.Apa"
cascade="none"
outer-join="auto"
constrained="false"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Kossa.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

package javaapplication3;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**
* @netbeans.hibernate.facade beanClass=javaapplication3.Kossa
*/
public class KossaFacade {
public void saveKossa(Kossa kossa) {
Session session = javaapplication3.NewHibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(kossa);
tx.commit();
javaapplication3.NewHibernateUtil.closeSession();
}

public void generate(){
Kossa kossa = new Kossa();
saveKossa(kossa);
}
}


Full stack trace of any exception that occurs:

Exception in thread "main" java.lang.ExceptionInInitializerError
at javaapplication3.NewHibernateUtil.getSessionFactory(NewHibernateUtil.java:42)
at javaapplication3.NewHibernateUtil.currentSession(NewHibernateUtil.java:53)
at javaapplication3.KossaFacade.saveKossa(KossaFacade.java:11)
at javaapplication3.KossaFacade.generate(KossaFacade.java:20)
at javaapplication3.Main.main(Main.java:32)
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property apa in class javaapplication3.Kossa
at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:216)
at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:209)
at org.hibernate.mapping.Property.getSetter(Property.java:265)
at org.hibernate.tuple.PojoEntityTuplizer.buildPropertySetter(PojoEntityTuplizer.java:259)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:122)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at javaapplication3.NewHibernateUtil.getSessionFactory(NewHibernateUtil.java:37)
... 4 more
Java Result: 1




But the bloody setter is clearly there!



package javaapplication3 ;
/**
*
*
* @hibernate.class
* table="KOSSA"
*
*/
public class Kossa {

// <editor-fold defaultstate="collapsed" desc=" PrimaryKey: String id ">
private String id;
/**
* @hibernate.id
* generator-class="uuid.hex"
*/
public String getId () {
return id;
}
public void setId (String id) {
this.id = id;
}
//</editor-fold>


// <editor-fold defaultstate="collapsed" desc=" 1-1 Relation to javaapplication3.Apa apa ">
private javaapplication3.Apa apa ;
/**
* @hibernate.one-to-one class = "javaapplication3.Apa"
*/
public javaapplication3.Apa getApa() {
return apa;
}
public void setApa() {
this.apa = apa;
}
// </editor-fold>

}


I've searched for hours but it seems noone has had this problem before. Really strange. Please help.


Top
 Profile  
 
 Post subject: Re: 1-1 relation -> "Could not find a setter for pro
PostPosted: Wed Apr 26, 2006 6:28 am 
Beginner
Beginner

Joined: Wed Apr 26, 2006 4:40 am
Posts: 24
sebstr wrote:
Hi, i'm having problem creating a 1-1 relation. 1-N works
private javaapplication3.Apa apa ;

public void setApa() {
this.apa = apa;
}


*cough*
Thought about putting "javaapplication3.Apa apa" into the argument section of your setter?

it should read:
public void setApa(javaapplication3.Apa apa) {
this.apa = apa;
}

;)


Top
 Profile  
 
 Post subject: Re: 1-1 relation -> "Could not find a setter for pro
PostPosted: Wed Apr 26, 2006 7:50 am 
Newbie

Joined: Tue Apr 25, 2006 4:34 am
Posts: 11
Thomson wrote:
sebstr wrote:
Hi, i'm having problem creating a 1-1 relation. 1-N works
private javaapplication3.Apa apa ;

public void setApa() {
this.apa = apa;
}


*cough*
Thought about putting "javaapplication3.Apa apa" into the argument section of your setter?

it should read:
public void setApa(javaapplication3.Apa apa) {
this.apa = apa;
}

;)

Holy crap!

When generating a 1-N relation it gets the set-method all correct. So I guess this is a bug in the plug-in...

This must be the most stupid thing I've spend four hours dealing with in my whole life. =)

Thanks for the answer!


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.