-->
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: Fetching only selected properties in collection. Help
PostPosted: Thu Aug 16, 2007 12:03 pm 
Newbie

Joined: Thu Aug 16, 2007 11:42 am
Posts: 2
Hibernate version: 3.2

Mapping documents:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Kategoria.hbm.xml
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

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

<hibernate-mapping>
<class name="pl.com.album.blc.Kategoria" table="kategoria">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="description" column="nazwa" not-null="true"/>

<set name="obrazki" table="obrazekwkategorii" lazy="true">
<key column="idKategorii" />
<many-to-many column="idObrazka" class="pl.com.album.blc.Obrazek"/>
</set>
</class>
</hibernate-mapping>


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Obrazek.hbm.xml
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

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

<hibernate-mapping>
<class name="pl.com.album.blc.Obrazek" table="obrazek">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="nazwa" column="nazwa" />
<property name="nazwaPliku" column="nazwapliku" not-null="true"/>
<property name="czasDodania" column="czasdodania" not-null="true"/>
<property name="obrazek" column="obrazek" length="1048576" not-null="true" lazy="true"/>
<property name="miniatura" column="miniatura" lazy="true"/>

<set name="kategorie" table="obrazekwkategorii" >
<key column="idObrazka" />
<many-to-many column="idKategorii" class="pl.com.album.blc.Kategoria"/>
</set>
</class>
</hibernate-mapping>


Hi. How can I write Hql query to fetch Kategoria with collection obrazki. The collection should be initializeb but not at all. Collection contains Obrazki and I don't wan't to initialize obrazek property and miniatura property because of it's size. It contains Image data and Thumbnail data.
How can I fetch collection in this case. I was looking for this on forum but found only this.

Use lazy="true" on <component>, and <property> mappings to enable lazy loading of individual scalar value-typed properties (a somewhat exotic case). Requires bytecode instrumentation of compiled persistent classes for the injection of interception code. Can be overriden in HQL with FETCH ALL PROPERTIES.

Is there any other way to acheve this?

Please help...


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.