-->
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: List, der list-index wird nicht erzeugt
PostPosted: Thu Jul 27, 2006 2:37 pm 
Newbie

Joined: Sun Nov 07, 2004 6:58 am
Posts: 8
Location: HH Germany
Hibernate version: 3.1.2

Mapping documents:


<class name="Picture" table="pictures" >
<!--cache usage="read-write"/-->
<id name="id" column="id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="name" column="name" />
<property name="filename" column="filename" />
<property name="created" column="created" />
<property name="height" column="height" />
<property name="width" column="width" />
<property name="vertical" column="vertical" />
<many-to-one name="owner" column="owner_id" class="User" />
<many-to-one name="type" column="type_id" class=".PictureType" />
<property name="description" column="description" />
<many-to-one name="original" column="original_id" unique="true" class="Picture" />
<set name="comments" inverse="true" >
<!--cache usage="read-write"/-->
<key column="picture_id"/>
<one-to-many class="PictureComment"/>
</set>
<many-to-one name="thumb" column="thumb_id" unique="true" class="Thumbnail" />
<many-to-one name="pictureLibrary" column="picturelibrary_id" class="PictureLibrary" />
<set name="sharedPictureLibrarys" inverse="true" table="pictures_sharedpicturelibrarys" >
<!--cache usage="read-write"/-->
<key column="picture_id"/>
<many-to-many column="sharedpicturelibrary_id" class="SharedPictureLibrary"/>
</set>
</class>

<class name="PictureLibrary" table="picturelibrarys" >
<!--cache usage="read-write"/-->
<id name="id" column="id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="name" column="name" />
<many-to-one name="defaultView" column="defaultview" class="View" />
<many-to-one name="thumbnail" column="thumbnail_id" class="Thumbnail" />
<many-to-one name="thumbView" column="thumbview" class="View" />
<many-to-one name="owner" column="owner_id" class="User" />
<list name="pictures" inverse="true" cascade="all">
<!--cache usage="read-write"/-->
<key column="picturelibrary_id"/>
<list-index column="picindex"/>
<one-to-many class="Picture"/>
</list>
<set name="thumbnails" inverse="true" >
<!--cache usage="read-write"/-->
<key column="picturelibrary_id"/>
<one-to-many class="Thumbnail"/>
</set>
<set name="sharedPictureLibrarys" inverse="true" >
<!--cache usage="read-write"/-->
<key column="picturelibrary_id"/>
<one-to-many class="SharedPictureLibrary"/>
</set>
</class>

Code between sessionFactory.openSession() and session.close():
ich verwende das Spring hibernate Template

Name and version of the database you are using:
MySQL 5.0

The generated SQL (show_sql=true):
ja das insert halt ohne die list-index spalte

als List verwende ich eine ArrayList.
da füge ich die Pictures über add hinzu.

eigentlich sollte dich Hibernate den indes automatisch setzen oder?
nur warum macht er das nicht?
könnte dies mit meinem zweiten problem zusammenhängen (Session Problem)

vielen Dank.

mfg Gideon


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 3:53 am 
Beginner
Beginner

Joined: Wed Sep 07, 2005 9:57 am
Posts: 20
Hi,

Das Problem ist das inverse="true".

Schau dir "Can't I have a bidirectional association using a List or Map?"

http://www.hibernate.org/116.html?cmd=prntdoc

an.


Viele Grüße,
Ronald


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 28, 2006 1:39 pm 
Newbie

Joined: Sun Nov 07, 2004 6:58 am
Posts: 8
Location: HH Germany
Hi,

danke das wars, jetzt funktioniert das zumindest.

habe dafür jetzt aber andere Probleme.

Code:
JDBC commit failed
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.


das kommt immer wenn ich mehrere items laden will und diese als Stream an den client schicke.

oder der hier, wenn Flushmode auf never steht.

Code:
2006-07-28 19:42:34,769 ERROR [org.hibernate.transaction.JDBCTransaction] - JDBC commit failed
java.sql.SQLException: Can't call commit when autocommit=true


manchma kommt das aber auch erst beim zweiten oder dritten request,

kann es sein das alle items gleichzeitig gelanden werden sollen, (es sind images) die auf der JSP über das <img tag angefordert werden.

wobei es sich um ein Servlet handelt das das eigentliche Image dann an den Browser schickt.

irgendwie sehr mekrwprdig das ganze.

danke nochmal

mfg Gideon


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.