-->
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: hand and program different behaviour?
PostPosted: Tue Feb 01, 2005 8:42 am 
Newbie

Joined: Tue Jan 25, 2005 1:00 pm
Posts: 5
Location: france
Hello world,

It seems thats doing hibernate's SQL request against my DB works
when i make it by hand : i got the expected result ( the good row) ...

Letting hibernate requesting by it own, i got and empty row ...

Hibernate version : hibernate-3.0beta2

Mapping documents:
<?xml version="1.0"?>
<!--
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
-->
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.equant.ref_ce.bo.ReBO" table="REFCE_RE">
<id name="reIdCedre">
<column name="RE_ID_CEDRE" sql-type="integer"/>
<generator class="assigned"/>
</id>
<property name="reNom">
<column name="RE_NOM" sql-type="varchar2(40)"/>
</property>
<property name="reLibLong">
<column name="RE_LIB_LONG" sql-type="varchar2(50)"/>
</property>
<property name="reRaisonSociale">
<column name="RE_RAISON_SOCIALE" sql-type="varchar2(38)"/>
</property>
<property name="reSegmentClient">
<column name="RE_SEGMENT_CLIENT" sql-type="varchar2(10)"/>
</property>
<property name="reSensibilite">
<column name="RE_SENSIBILITE" sql-type="varchar2(20)"/>
</property>
<property name="reCscCedre">
<column name="RE_CSC_CEDRE" sql-type="varchar2(20)"/>
</property>
<property name="reIdRsc" type="big_decimal">
<column name="RE_ID_RSC"/>
</property>
<property name="reAssistRsc">
<column name="RE_ASSIST_RSC" sql-type="varchar2(50)"/>
</property>
<property name="reDecideur">
<column name="RE_DECIDEUR" sql-type="varchar2(50)"/>
</property>
<property name="reCrao">
<column name="RE_CRAO" sql-type="varchar2(50)"/>
</property>
<property name="reCommentaire">
<column name="RE_COMMENTAIRE" sql-type="varchar2(255)"/>
</property>
<property name="reDateCreate" type="timestamp">
<column name="RE_DATE_CREATE"/>
</property>
<set name="ReseauCompteBOSet"
inverse="true"
cascade="save-update">
<key column="RE_ID_CEDRE"/>
<one-to-many class="com.equant.ref_ce.bo.ReseauCompteBO"/>
</set>
<set name="produitCeBOSet"
inverse="true"
cascade="save-update">
<key column="RE_ID_CEDRE"/>
<one-to-many class="com.equant.ref_ce.bo.ProduitCeBO"/>
</set>
<set name="sousReseauBOSet"
inverse="true"
cascade="save-update">
<key column="SR_ID"/>
<one-to-many class="com.equant.ref_ce.bo.SousReseauBO"/>
</set>
<set name="arAliasReBOSet"
inverse="true"
cascade="save-update">
<key column="RE_ID_CEDRE"/>
<one-to-many class="com.equant.ref_ce.bo.ArAliasReBO"/>
</set>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
reIdCedre=new Integer(2147483647);
reBO = (ReBO) session.load(ReBO.class, reIdCedre);

Full stack trace of any exception that occurs::
No row with the given identifier exists: [com.equant.ref_ce.bo.ReBO#2147483647]
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.equant.ref_ce.bo.ReBO#2147483647]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:719)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:115)
at com.equant.ref_ce.bo.ReBO$$EnhancerByCGLIB$$2f6fae24.toString(<generated>)
at java.lang.String.valueOf(String.java:2131)
at java.lang.StringBuffer.append(StringBuffer.java:370)
at com.equant.ref_ce.dao.ReDataBaseManager.retrieveReByReIdCedre(ReDataBaseManager.java:85)
at com.equant.ref_ce.test.dao.TestSousReseauDataBaseManager.testSousReseauManager(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.equant.ref_ce.test.dao.TestCase.runTest(Unknown Source)

Name and version of the database you are using:
oracle 9i

The generated SQL (show_sql=true) and a little more ... :
[junit] 13:11:38,625 DEBUG DefaultLoadEventListener: loading entity: [com.equant.ref_ce.bo.ReBO#2147483647]
[junit] 13:11:38,625 DEBUG DefaultLoadEventListener: creating new proxy for entity
[junit] 13:11:38,625 DEBUG DefaultLoadEventListener: attempting to resolve: [com.equant.ref_ce.bo.ReBO#2147483647]
[junit] 13:11:38,625 DEBUG DefaultLoadEventListener: object not resolved in any cache: [com.equant.ref_ce.bo.ReBO#2147483647]
[junit] 13:11:38,625 DEBUG BasicEntityPersister: Materializing entity: [com.equant.ref_ce.bo.ReBO#2147483647]
[junit] 13:11:38,640 DEBUG AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[junit] 13:11:38,640 DEBUG SQL: select rebo0_.RE_ID_CEDRE as RE_ID_CE1_0_, rebo0_.RE_NOM as RE_NOM6_0_, rebo0_.RE_LIB_LONG as RE_LIB_L3_6_0_, rebo0_.RE_RAISON_SOCIALE as RE_RAISO4_6_0_, rebo0_.RE_SEGMENT_CLIENT as RE_SEGME5_6_0_, rebo0_.RE_SENSIBILITE as RE_SENSI6_6_0_, rebo0_.RE_CSC_CEDRE as RE_CSC_C7_6_0_, rebo0_.RE_ID_RSC as RE_ID_RSC6_0_, rebo0_.RE_ASSIST_RSC as RE_ASSIS9_6_0_, rebo0_.RE_DECIDEUR as RE_DECI10_6_0_, rebo0_.RE_CRAO as RE_CRAO6_0_, rebo0_.RE_COMMENTAIRE as RE_COMM12_6_0_, rebo0_.RE_DATE_CREATE as RE_DATE13_6_0_ from REFCE_RE rebo0_ where rebo0_.RE_ID_CEDRE=?
[junit] Hibernate: select rebo0_.RE_ID_CEDRE as RE_ID_CE1_0_, rebo0_.RE_NOM as RE_NOM6_0_, rebo0_.RE_LIB_LONG as RE_LIB_L3_6_0_, rebo0_.RE_RAISON_SOCIALE as RE_RAISO4_6_0_, rebo0_.RE_SEGMENT_CLIENT as RE_SEGME5_6_0_, rebo0_.RE_SENSIBILITE as RE_SENSI6_6_0_, rebo0_.RE_CSC_CEDRE as RE_CSC_C7_6_0_, rebo0_.RE_ID_RSC as RE_ID_RSC6_0_, rebo0_.RE_ASSIST_RSC as RE_ASSIS9_6_0_, rebo0_.RE_DECIDEUR as RE_DECI10_6_0_, rebo0_.RE_CRAO as RE_CRAO6_0_, rebo0_.RE_COMMENTAIRE as RE_COMM12_6_0_, rebo0_.RE_DATE_CREATE as RE_DATE13_6_0_ from REFCE_RE rebo0_ where rebo0_.RE_ID_CEDRE=?
[junit] 13:11:38,640 DEBUG AbstractBatcher: preparing statement
[junit] 13:11:38,687 DEBUG IntegerType: binding '2147483647' to parameter: 1
[junit] 13:11:38,734 DEBUG AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
[junit] 13:11:38,734 DEBUG Loader: Using naked result set
[junit] 13:11:38,734 DEBUG Loader: processing result set
[junit] 13:11:38,734 DEBUG Loader: done processing result set (0 rows)
[junit] 13:11:38,734 DEBUG AbstractBatcher: about to close ResultSet (open ResultSets: 1, globally: 1)
[junit] 13:11:38,734 DEBUG AbstractBatcher: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[junit] 13:11:38,734 DEBUG AbstractBatcher: closing statement
[junit] 13:11:38,734 DEBUG Loader: total objects hydrated: 0
[junit] 13:11:38,734 DEBUG PersistenceContext: initializing non-lazy collections

Where is the thing i don't understand so i got the ObjectNotFoundException doing it programaticaly ?

please help,

thx,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 10:37 am 
Newbie

Joined: Tue Jan 25, 2005 1:00 pm
Posts: 5
Location: france
Maybe found an an explanation ?

Until now it was working.
The only thing that changed is my Oracle client to view my tables (Toad) showed to me NUMBER for INTEGER ... (maybe a DBA intervention ?)

Indeed some of my collumns (and specially this PK) was defined, created
as an INTEGER :

create table REFCE_RE (
RE_ID_CEDRE INTEGER not null,
RE_NOM VARCHAR2(40) not null,
...../.....
)

<id name="reIdCedre">
<column name="RE_ID_CEDRE" sql-type="integer"/>
<generator class="assigned"/>
</id>

First, i believed it shoudn't matter as NUMBER and INTEGER are PL/SQL
Subtypes/Synonyms for oracle (http://www.ss64.com/orasyntax/datatypes.html)

Now, i've defined my hibernate mapping as follow :

<id name="reIdCedre">
<column name="RE_ID_CEDRE" sql-type="number"/>
<generator class="assigned"/>
</id>

In this case reIdCedre is still an int

I'm worried as usually sql-type="number" is supposed to be mapped
with a java.lang.BigDecimal, Isn't it ?

Maybe it could help someone else.


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.