-->
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.  [ 13 posts ] 
Author Message
 Post subject: Need help obout <properties>
PostPosted: Thu May 31, 2007 12:16 pm 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
I have this maping:
<class name="SchemeItem" table="scheme" optimistic-lock="none">
.
.
<properties name="aa21" update="true" insert="true" >
<property name="code" type="string" column="code" not-null="true"/>
<property name="idVersion" type="integer" column="id_version" not-null="true" update="false" insert="false"/>
</properties>
<set name="measureUnits">
<key property-ref="aa21">
<column name="code"/>
<column name="id_scheme"/>
</key>
<one-to-many class="SchemeItemUnits"/>
</set>
</class>

And after test like:
session.get(SchemeItem.class, 12873);

Exception in thread "main" java.lang.ClassCastException: mytest.SchemeItem
at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:355)
at org.hibernate.type.CollectionType.resolve(CollectionType.java:368)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at mytest.ProbaSchemeItem.main(ProbaSchemeItem.java:24)


Any ideas what to do?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 1:39 pm 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
I can't belive than nobady never uded <properties> . This is amazing.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 2:02 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Try with this:
Code:
<class name="mytest.SchemeItem" table="scheme" optimistic-lock="none">


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 2:55 pm 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
Are you kidding?!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:05 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Are you?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:19 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Maybe if I tell you that you didn't post the line

Code:
<hibernate-mapping package="mytest">


you will understand the joke.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:29 pm 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
Muhhahaha hahaha.
Ok.I will tell you more details obout the problem
( please excuse me for bad language)

I have 2 tables
Scheme{
someColumn1 ..
someColun2 ...
.
code VARCHAR,
id_version INT,
.
}

Schem_Unit{
SomeColumn...
..
..
code VARCHAR,
id_scheme INT,
...
..}

and
SCHEME.CODE = SCHEME_UNIT.CODE and
SCHEME.ID_VERSION=SCHEME_UNIT.ID_SCHEME

this is very simple situacion in SQL life but may be in HIBERNATE this is advaced ?????

So. The only way that I find is to create <properirs group.

Id we comment all <set> sectio there is not proble. that mean that


<class name="mytest.SchemeItem" table="scheme" optimistic-lock="none"> is not the desision.

Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 4:38 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Post your full map file.
Between [code] [/code] tags please


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 4:58 pm 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
Code:
<hibernate-mapping schema="informix" package="mytest">
  <class name="mytest.SchemeItem" table="scheme" optimistic-lock="none">
    <id name="id" type="integer" unsaved-value="null" column="id">
      <generator class="native"/>
    </id>
    <property name="numberItem" type="integer" column="number_item" not-null="true"/>
    <property name="text" type="string" column="text" length="255" not-null="true"/>
    <property name="levelNumber" type="integer" column="level_number" not-null="true"/>
    <property name="parrentCode" type="integer" column="parrent_code"/>
    <property name="indChild" type="integer" column="ind_child" not-null="true"/>
   
    <properties name="aa21" update="true" insert="true" >
      <property name="code" type="string" column="code" not-null="true"/>
      <property name="idVersion" type="integer" column="id_version" not-null="true" update="false" insert="false"/>
    </properties>
     <bag name="measureUnits">
      <key property-ref="aa21">
        <column name="code"/>
        <column name="id_scheme"/>
      </key>
      <one-to-many  class="SchemeItemUnits"/>
    </bag>
   
  </class>


and
Code:
  <class name="SchemeItemUnits" table="scheme_units" optimistic-lock="none">
    <id name="id" type="integer" unsaved-value="null">
      <column name="id" not-null="true" unique="true" index="191_382"/>
      <generator class="native"/>
    </id>
   
    <property name="code" type="string" column="code" length="50" not-null="true"/>
    <property name="type" type="short" column="type" not-null="true"/>
    <property name="unit" type="string" column="unit" length="50" not-null="true"/>
    <property name="idScheme" type="integer" column="id_scheme" not-null="true"/>
  </class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 5:48 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Well, at first sight it looks fine.
What about the POJOS?
(mytest.SchemeItem and mytest.SchemeItemUnits)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 1:55 am 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
Code:
public class SchemeItem {

   
   private Integer   id;
   private Integer   numberItem;
   private String   code;
   private String   text;
   private Integer   levelNumber;
   private Integer   parrentCode;
   private Integer   indChild;
   private Integer   idVersion;
   
   private Set<SchemeItemUnits> measureUnits;

   
   
   /** auto generated
    * @es_generated
    */
   public SchemeItem() {
      super();
   }

    .......
     For all I have Getters and Setters
}



Code:
public class SchemeItemUnits {

   private Integer   id;
   private String   code;
   private Short   type;
   private String   unit;
   private Integer   idScheme;

   public SchemeItemUnits() {
      super();
   }
   ..........
       .......
     For all I have Getters and Setters   
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 6:23 am 
Beginner
Beginner

Joined: Fri Feb 10, 2006 8:33 am
Posts: 32
The solution is:

The POJO must implements Serializable


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 4:42 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Why?
It has to be a bug.


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