-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem: Same object reference in query result
PostPosted: Thu Aug 25, 2005 7:54 am 
Newbie

Joined: Thu Aug 25, 2005 7:46 am
Posts: 2
Hello to all of you!

I have a problem with Hibernate 3.0.5 under Eclipse.

Fot most of the tables in my DB (sqlserver), every query goes ok but for one of them, the queries (select * from...) ALWAYS return the exact number of reference to objects I would have expected (1 for each rows) except that almost every reference points to the same object!

I tried to do these requests with the eclipse tools or hard coded in a Java program but the results are the same. Actually, I even tried using ObjectVisualiser with the Hibernate plugin : same result!

The only difference I've found between this table and the others is that it has a string key where the others have integer keys...

Help would be greatly appreciated (I've spent too much time searching and I have deadlines to achieve)

Thx!


Top
 Profile  
 
 Post subject: more info
PostPosted: Thu Aug 25, 2005 11:43 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Please provide more information with the usual template:
version, mappings, code between session open and close, etc.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 4:22 am 
Newbie

Joined: Thu Aug 25, 2005 7:46 am
Posts: 2
the mapping and session factory

<session-factory>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.show_sql">true</property>

<!-- General mapping associations -->

<mapping resource="Functions.hbm.xml" />
</session-factory>


The mapping file

<hibernate-mapping>
<class name="Functions" table="Functions" schema="dbo" catalog="common">
<id name="functionNb" type="character">
<column name="FunctionNb" length="10" />
<generator class="assigned" />
</id>
<property name="functionName" type="string">
<column name="FunctionName" length="250" />
</property>
<property name="niveau" type="integer">
<column name="Niveau" />
</property>
<property name="bg" type="integer">
<column name="bg" />
</property>
<property name="bd" type="integer">
<column name="bd" />
</property>
</class>
</hibernate-mapping>

and the code for the session factory

try {
// Create the SessionFactory from hibernate.cfg.xml
// sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory = new Configuration().configure("file.cfg.xml").buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}


Anyway, all the files have been generated by the artifact generator, and I haven"t modified anything. I've deliberately erased the DBs information in this posts but they are right since I can connect to it and retrieve records with all the other objects (well, with this one too but always the same reference)

Well actually, I've already found someone who already had the same problem on the forum but he resolved it by writing a full query ('select ... from') and not a simplified one ('from...'). Anyway, in my case, it's already a full query and using the eclipse tool, hql, or simplified queries doesn't change anything neither.


Top
 Profile  
 
 Post subject: code
PostPosted: Fri Aug 26, 2005 11:06 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
What exactly the code between session.open() and session.close()?

And by the way there is duplicate property 'bg' mapping in the hbm file you provided.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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