-->
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.  [ 1 post ] 
Author Message
 Post subject: pb de chargement avec <load-collection> mais pas d'exc
PostPosted: Fri Aug 31, 2007 11:16 am 
Newbie

Joined: Fri Aug 31, 2007 10:50 am
Posts: 4
bonjour,
j'ai un gros soucis avec un mapping hibernate et n'est trouve que peu de
documentation sur le sujet:

voici un bout du mapping que j'utilise :

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

<hibernate-mapping package="xxx.domain">
<class name="Artifact" table="artifact">
<meta attribute="sync-DAO">false</meta>
<id name="id" type="java.lang.Long" column="id">
<generator class="native" />
</id>
<natural-id>
<property name="name" column="name" type="string"
not-null="true" length="45" unique="true" />
</natural-id>
<property name="title" column="title" type="string"
not-null="false" length="120" />
<property name="leftIndex" column="lft" type="java.lang.Integer"
not-null="true" />
<property name="rightIndex" column="rgt"
type="java.lang.Integer" not-null="true" />
<many-to-one name="artifactType" column="fk_artifacttype_id"
class="ArtifactType" not-null="true">
</many-to-one>

<many-to-one name="publication" column="fk_publication_id"
class="Publication" not-null="true">
</many-to-one>


<set name="fragments" inverse="true" lazy="true">
<key column="id" />
<one-to-many class="Fragment" />
</set>


<set name="artChildrens" lazy="true" inverse="true">
<key />
<one-to-many class="Artifact" />
<loader query-ref="xxx.domain.Artifact.childrens" />
</set>

<sql-query name="childrens">
<load-collection alias="node" role="Artifact.artChildrens" />
SELECT {node.*},
(COUNT(parent.name) - (sub_tree.depth + 1)) AS depth
FROM artifact node,
artifact parent,
artifact sub_parent,

(
SELECT
node.name, (COUNT(parent.name) - 1) AS depth
FROM artifact node, artifact parent
WHERE node.lft BETWEEN parent.lft
AND parent.rgt
AND node.id = :id
GROUP BY node.name
ORDER BY node.lft
)
AS sub_tree
WHERE node.lft BETWEEN parent.lft
AND parent.rgt
AND node.lft BETWEEN sub_parent.lft
AND sub_parent.rgt
AND sub_parent.name = sub_tree.name
GROUP BY node.name
HAVING depth = 1
ORDER BY node.lft
</sql-query>


</class>


j'utilise une requete sql native pour charger une collection 'artChildrens'.
En testant, tout se passe correctement la log m'indique que la requete est executee et le resultset contient les donnees.
mais la collection 'set' mappee dans mon bean est toujours vide !?

en regardant le source, j'ai remarquer que la classe effectuer l'initialisation etait la suivante NamedQueryCollectionInitializer l-54

"query.setCollectionKey( key )
.setFlushMode( FlushMode.MANUAL )
.list();"
la commande retourne bien lune liste d'objet correspondant a ma requete mais elle est initialisee null part ?

sinon j'effectue les tests dans un test junit avec spring :
AbstractTransactionalDataSourceSpringContextTests

version hibernate :3.2.5
base mysql 5.0


merci de votre aide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.