-->
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: Incorrect generated SQL, possible mapping problems
PostPosted: Tue Jun 28, 2005 11:30 am 
Newbie

Joined: Tue Jun 28, 2005 11:11 am
Posts: 13
Location: St. Louis, Missouri, USA
Hibernate version:3.current

Mapping documents:
Note: I do not know if the key is just AREA_ID or AREA and AREA_ID, but the key regardless isn't anything auto-generated.
<hibernate-mapping>

<class
name="test.bo.AreaBO"
table="LOCATIONS_AREA_T"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="areaID"
column="AREA_ID"
type="string"
unsaved-value="0"
>
<generator class="native"/>
</id>

<property
name="area"
type="string"
update="false"
insert="false"
column="AREA"
not-null="true"
unique="true"
lazy="true"
/>

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():(Spring Framework) but my call to Hibernate though Spring is: AreaBO area = (AreaBO) getHibernateTemplate().load(AreaBO.class, "11A");

Full stack trace of any exception that occurs: None.

Name and version of the database you are using:Oracle 9.2.0.6.0 (WSAD 5.1.x)

The generated SQL (show_sql=true):select areabo0_.AREA_ID as AREA1_0_ from FORM4248_AREA areabo0_ where areabo0_.AREA_ID=?

Debug level Hibernate log excerpt:

The table/row I am quering looks like
AREA: Southern Illinois
AREA_ID: 11A

And my problem is that Hibernate is only asking for the area_id, when in fact I am asking for the whole object which I understand to be the WHOLE record that I specified in my mapping xml file. Amazingly when my AreaBO gets created the area and areaID are the same.

I think the problem may be with the key or id. Our databases only use composite keys which represent the data and which will always be unique because we won't allow duplicates or nulls.

I'm very new to Hibernate and not sure where to even look for this answer as I'm not sure if this is a xml mapping issue or if I have something with Spring/Hibernate misconfigured.

Any help is appreciated. So far, I like what I see. Just wish the learning curve wasn't so steep, but hey, the authors mention that fact at least twice in the "Hibernate in Action" book so I can't complain.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 4:30 pm 
Newbie

Joined: Tue Jun 28, 2005 11:11 am
Posts: 13
Location: St. Louis, Missouri, USA
I modified my earlier code and proceeded to get the same results. I followed how Spring calls Hibernate functions and outside of Spring called the same methods as my Spring method would call. This resulted in the expected results.

Why the Hibernate calls inside of Spring aren't working but ARE working when called outside of Spring is a mystery to me.

If anyone has anything on this to share, please post. I will promptly fill out bug reports with Spring when I get home from work.

I have a corresponding thread on Spring's forums here: http://forum.springframework.org/viewto ... 6129#26129.

Thanks.


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.