[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
Rob Harrington (JIRA)
noreply at atlassian.com
Mon Mar 3 18:04:35 EST 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29652 ]
Rob Harrington commented on HHH-951:
------------------------------------
I am seeing this in 3.2.5.ga. I am working on porting from 3.0.5, for which this was not an issue. For me, it's not a case sensitivity issue, or not qualifying the column with a table name or alias. Using the Criteria API, something like this:
Criteria crit = buildQuery(opt); // huge method left out for brevity
crit.setFirstResult(0);
crit.setMaxResults(25);
c = crit.list();
results in something like this for SQL:
SELECT *
FROM (SELECT this_.io_item_a_id AS io1_14_5_,
this_.creation_dt AS creation2_14_5_,
.
.
.
this_.package_main_fl AS package15_14_5_,
this_.insertion_order_id AS insertion16_14_5_, --dupe
this_.solomon_item_id AS solomon17_14_5_,
this_.parent_io_item_a_id AS parent18_14_5_,
this_.line_group_id AS line19_14_5_,
this_.io_item_state_cd AS io20_14_5_,
this_.insertion_order_id AS insertion16_14_5_, --dupe
this_.assignment_id AS assignment21_14_5_,
.
.
.
packageins9_.package_instance_id AS package1_84_4_,
packageins9_.bundle_cd AS bundle2_84_4_
FROM [removed for brevity]
WHERE [removed for brevity]
ORDER BY [removed for brevity]
)
WHERE ROWNUM <= 25
So as you can see 'this_.insertion_order_id' is included twice with the same alias. Obviously I've left out a LOT of detail and no Test Case. Not including that for now in the hope that I've described the issue well enough to get feedback on whether this is a known issue or indeed requires more description (test case) from me, which will take a while to put together.
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1 beta 2
> Environment: hibernate3.0.5, hibernate3.1b2, Oracle 9
> Reporter: Karel Sommer
>
> when create criteria with associations, i get this error:
> ORA-00918: column ambiguously defined
> mapping:
> <class name="User" table="FRAME_USER" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_user_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="user_name" type="string" not-null="true"/>
> <property name="blocked" type="yes_no" not-null="true"/>
> <property name="access_logon" type="timestamp"/>
> <property name="denied_logon" type="timestamp"/>
> <property name="inactivity_time" type="long"/>
> <property name="session_count" type="long"/>
> <idbag name="terminalGroups" table="FRAME_USER_TERMINAL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long">
> <generator class="sequence">
> <param name="sequence">frame_user_terminal_seq</param>
> </generator>
> </collection-id>
> <key column="id_user"/>
> <many-to-many column="id_terminal_groups" class="TerminalGroup" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="TerminalGroup" table="FRAME_TERMINAL_GROUPS" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_groups_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="name" column="group_name" type="string" not-null="true"/>
> <idbag name="terminals" table="FRAME_TERMINAL_REL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long" >
> <generator class="sequence">
> <param name="sequence">frame_terminal_rel_seq</param>
> </generator>
> </collection-id>
> <key column="id_term_group"/>
> <many-to-many column="id_term" class="Terminal" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="Terminal" table="FRAME_TERMINAL" where="status != 'D'" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="status" type="char" not-null="true"/>
> <property name="mac" type="string" not-null="true"/>
> <property name="name" column="ident" type="string" not-null="true"/>
> <property name="description" type="string"/>
> code:
> session.createCriteria(User.class)
> .add(Restrictions.like("user_name", "%")
> .createCriteria("terminalGroups")
> .add( Restrictions.like("group_name", "%").
> .setProjection(Projections.rowCount())
> .uniqueResult();
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list