-->
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.  [ 5 posts ] 
Author Message
 Post subject: StackOverFlow
PostPosted: Wed Sep 08, 2004 3:04 am 
Newbie

Joined: Wed Sep 08, 2004 2:49 am
Posts: 3
Hibernate version: 2.1

Mapping documents: Detay.hbm.xml , Kayit.hbm.xml

Code between sessionFactory.openSession() and session.close():
Kayit kay = new Kayit();
Detay det = new Detay();
Session s = sf.openSession();
Transaction t = s.beginTransaction();
det.setAd("Burak");
det.setSoyad("Ilter");

kay.setUsername("burak");
kay.setPassword("123456");

det.setKayit(kay);
System.out.println("det is set");
kay.setDetay(det);
Query q = s.createQuery("from Kayit kayit where kayit.username = :name");
q.setString("name", "canhuzmeli");
Iterator iter = q.iterate();
while(iter.hasNext() ){
Kayit cikti = (Kayit) iter.next();
System.out.println(cikti.getPassword());
}
s.save(det);
s.save(kay);
t.commit();
s.close();

Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.StackOverflowError
Name and version of the database you are using:
MySql 4.0.18

I have a record
I get the output of "det is set" and the password of canhuzmeli, however the program flows when it tries to save the sessions.(I think so)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 3:11 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
Can I ask why you have to save both?
Quote:
s.save(det);
s.save(kay);


saving det only is enough, depending on your mapping(not shown here), and kay will be persisted as well


Top
 Profile  
 
 Post subject: mappings:
PostPosted: Wed Sep 08, 2004 3:37 am 
Newbie

Joined: Wed Sep 08, 2004 2:49 am
Posts: 3
I tried every possible savings (saving only one of them, both of them....) however I always get the same error.

<hibernate-mapping package = "havelsan.hiber">

<class name="Kayit" table="auth">

<id name="id" type="integer" unsaved-value="null" >
<column name="ID" sql-type="int" not-null="true" length="11"/>
<generator class="foreign">
<param name="property">detay</param>
</generator>
</id>

<property name="username">
<column name="USERNAME" sql-type="varchar" not-null="true" length="16"/>
</property>

<property name="password">
<column name="PASSWORD" sql-type="varchar" not-null="true" length="16"/>
</property>

<one-to-one name="detay" class="Detay" constrained="true"/>

</class>

</hibernate-mapping>




<hibernate-mapping package = "havelsan.hiber">

<class name="Detay" table="detaylar">

<id name="id" type="integer" unsaved-value="null" >
<column name="ID" sql-type="int" not-null="true" length="11"/>
<generator class="foreign">
<param name="property">kayit</param>
</generator>
</id>

<property name="ad">
<column name="AD" sql-type="varchar" not-null="false" length="16"/>
</property>

<property name="soyad">
<column name="SOYAD" sql-type="varchar" not-null="false" length="16"/>
</property>
<one-to-one name="kayit" class="Kayit" />
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 4:02 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
Ok, this trying this and that usually takes a long time to work, and if it does in the end you geenrally have no idea why, if you haven't first figured out what results you expect, you can't work toward achieving it.
so start by deciding which object will cascade updates, which updates should be cascaded, and read the doc on how to map one-to-one, there are 2 options, and your mapping isn't one of them.
If you still have a problem feel free to post again


Top
 Profile  
 
 Post subject: sorry
PostPosted: Wed Sep 08, 2004 7:47 am 
Newbie

Joined: Wed Sep 08, 2004 2:49 am
Posts: 3
sorry for being so lazy. I found my answers in FAQ.
thanks for your concern.


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