-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with composite-id and lazy=true
PostPosted: Sat Jun 10, 2006 10:39 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi,

I have the series that contains a list of seriesColors,
and I have color that contains a list of seriesColors too.

I´m using the classes with lazy="true", like the following mapping:

Code:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Codification.SeriesTO,TO"
        table="cod_serie" lazy="true">

      <id name="Id" column="id_serie">
      <generator class="identity"/>
      </id>
   
      <property name="Name" column="no_serie"/>
      <property name="Code" column="cd_serie"/>
      <property name="Price" column="preco"/>

    <bag name="SeriesColors" inverse="true" lazy="true">
      <key column="id_serie"/>
      <one-to-many class="Codification.SeriesColorTO, TO"/>
    </bag>

  </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Codification.ColorTO,TO"
        table="cod_cor" lazy="true">

      <id name="Id" column="id_cor">
      <generator class="identity"/>
      </id>
   
      <property name="Code" column="cd_cor"/>
      <property name="Name" column="no_cor"/>
      <property name="HexCode" column="cd_hex_cor"/>

    <bag name="SeriesColors" inverse="true" lazy="true">
      <key column="id_cor"/>
      <one-to-many class="Codification.SeriesColorTO, TO"/>
    </bag>

   </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Codification.SeriesColorTO,TO"
        table="cod_serie_x_cor" lazy="true">

    <composite-id>
      <key-many-to-one name="Series" column="id_serie"
                       class="Codification.SeriesTO,TO"/>
      <key-many-to-one name="Color" column="id_cor"
                       class="Codification.ColorTO,TO"/>
    </composite-id>
   
    <property name="Price" column="preco"/>
   
   </class>
</hibernate-mapping>



When I try to use the session.Find with hql like:

[code]
FROM SeriesColorTO seriescolor
[code]

It doesn´t returns (return null) the object color and series within SeriesColor.
When I change the classes, removing the lazy=true, The method returns the objects
of composite-id. But I need to do with lazy=true, because the classes will be used
in others classes, and I need performance loading only the objects that I want.

I changed the hql to use inner join fetch, but it doesn´t returns too:

[code]
FROM SeriesColorTO seriescolor
INNER JOIN FETCH seriescolor.Series series
INNER JOIN FETCH seriescolor.Color color
[/code]

somebody knows about this?

thanks!!!!

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 2:31 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
If I use sess.get(..) in some cases doesn´t works by using the
NHibernateUtil.Initialize(...):

Code:
SeriesColorTO seriescolor = (SeriesColorTO) Hst.Database.NHibernate.NHibernateUtil.GetSession().Get(typeof(SeriesColorTO), id_);

NHibernateUtil.Initialize(seriescolor.Series);
NHibernateUtil.Initialize(seriescolor.Color);


Somebody uses the lazy=true to classes???

thanks!!!!

_________________
Tads


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