-->
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: Hibernate3 and Oracle 10g
PostPosted: Fri Dec 22, 2006 6:18 am 
Newbie

Joined: Fri Dec 22, 2006 6:02 am
Posts: 2
Hi,

I am using Hibernate 3 and oracle 10g. When using <many-to-one> mapping between two tables for example Employee and Department, hibernate throws the following exception


WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 918, SQLState: 42000>
ERROR [org.hibernate.util.JDBCExceptionReporter] - <ORA-00918: column ambiguously defined


I have found that the above error is due to using of the method setMaxRows() The same code i have tested for other databases and it is working fine. It seems that this problem was identified before but unfortunately i was not able to find the right solution. If it already solved please do guide me to the link, i would appreciate that a lot.


Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 6:02 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Please post your mappings... You should also try and generate your sql schema using SchemaUpdate: it would allow you to verify if the SQL corresponding to what you mapped is in fact the one you were meaning to do :-)

See http://www.hibernate.org/hib_docs/v3/re ... etguide-s1

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject: This mapping works for other dbs such as Mysql but not oracl
PostPosted: Fri Dec 29, 2006 11:07 am 
Newbie

Joined: Fri Dec 22, 2006 6:02 am
Posts: 2
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="EmplMaster" table="empl_master">
<id column="EmployeeId" name="employeeId" type="string">
</id>
<property column="DepartmentCode" length="10" name="departmentcode" type="string" />
<property column="Supervisor" length="50" name="supervisor" type="string"/>

<many-to-one name="department" class="Department" column="departmentcode" not-null="true" lazy="false" optimistic-lock="true" insert="false" update="false" outer-join="true" unique="false">
</many-to-one>
</class>

<query name="empList">
<![CDATA[from EmplMaster as e left join fetch e.department]]>
</query>


</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: This mapping works for other dbs such as Mysql but not o
PostPosted: Fri Dec 29, 2006 12:48 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It seems like you defined your department property twice. Once in a simple property, once in the many-to-one definition. Was it made on purpose? If so, which one?

Hence, I guess you should replace the provided mapping with the following (please use code tags when pasting code) :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="EmplMaster" table="empl_master">
      <id column="EmployeeId" name="employeeId" type="string">
      </id>
<!-- comment it out
      <property column="DepartmentCode" length="10" name="departmentcode" type="string" />
-->
      <property name="supervisor" column="Supervisor" length="50" />
      
      <many-to-one name="department" class="Department"
                   column="departmentcode" not-null="true" lazy="false"
                   optimistic-lock="true" insert="false" update="false" outer-join="true" unique="false">
      </many-to-one>
   </class>
   
   <query name="empList">
      <![CDATA[from EmplMaster as e left join fetch e.department]]>
   </query>   
   
</hibernate-mapping>

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.