[Hibernate-JIRA] Commented: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
by Shawn Kerstetter (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=co... ]
Shawn Kerstetter commented on HHH-951:
--------------------------------------
I should include the log files depicting the error:
[exec] 15:58:16,484 DEBUG [SQL] select * from ( select testhhh951x0_.primaryKey as primaryKey417_, testhhh951x0_.TRANID as TRANID417_, testhhh951x0_.tranid as tranid417_ from TestHHH951 testhhh951x0_ ) where rownum <= ?
[exec] 15:58:16,593 WARN [JDBCExceptionReporter] SQL Error: 918, SQLState: 42000
[exec] 15:58:16,593 ERROR [JDBCExceptionReporter] ORA-00918: column ambiguously defined
*ALSO* note that the work around is really simple, just use UPPERCASE column names.
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate Core
> 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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months
[Hibernate-JIRA] Commented: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
by Shawn Kerstetter (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=co... ]
Shawn Kerstetter commented on HHH-951:
--------------------------------------
+1
This is really not all that hard to reproduce.
1. You need to map the same column 2x
2. You need to have a case mismatch between the columns in the mappings
3. You need to use setMaxResults()
4. You need to be using ORA (works fine on MSSQL)
Here's some code from which I think it should be trivial to derive a test case in your favorite framework:
<code>
@Entity
public class TestHHH951 extends BaseEntity {
@Id
private Integer primaryKey;
//note case and column name
@Column(name="TRANID", nullable=false)
private Integer tranID;
//note duplicate column name/mapping and mismatched case
@Column(name="tranid", nullable=false, insertable=false, updatable=false)
private Integer duplicateTranID;
</code>
<code>
public void testHHH951() {
TestHHH951 entity = new TestHHH951();
entity.setPrimaryKey(IdGenerator.nextId(TestHHH951.class));
entity.setTranID(IdGenerator.nextId(TestHHH951.class));
//CRUD works fine:
entity = create(entity);
entity = read(entity);
entity.setTranID(IdGenerator.nextId(TestHHH951.class));
entity = update(entity);
//expected to fail (and does)
assertCollectionsEqual(Arrays.asList(entity), getService().listAll(TestHHH951.class, null));
}
</code>
Where list all is essentially:
<code>
return getEntityManager().createQuery("From TestHHH951").setMaxResults(MAX_RESULTS).getResultList();
</code>
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate Core
> 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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months
[Hibernate-JIRA] Created: (HBX-1107) <jdbcconfiguration> tag does not support the <mapping> tags defined in the hibernate.cfg.xml
by Julien Kronegg (JIRA)
<jdbcconfiguration> tag does not support the <mapping> tags defined in the hibernate.cfg.xml
--------------------------------------------------------------------------------------------
Key: HBX-1107
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1107
Project: Hibernate Tools
Issue Type: Bug
Components: ant
Affects Versions: 3.2beta10
Environment: JDK 1.5.0 (IBM J9 VM 2.3)
Reporter: Julien Kronegg
Priority: Minor
Hibernate Tools documentation states that Ant tasks can be configured using JDBC configuration (http://www.hibernate.org/hib_docs/tools/reference/en/html_single/#d0e1053). Specifying already existing mappings is allowed by two means:
1) in the hibernate.cfg.xml
2) in a Ant fileset as a child of the <jdbcconfiguration> tag
The parent <configuration> tag documentation states that a standard Ant fileset can be inserted to include hibernate mapping files and prevent from duplicating mappings in hibernate.cfg.xml:
"A standard Ant fileset. Used to include hibernate mapping files.Remember that if mappings are already specified in the hibernate.cfg.xml then it should not be included via the fileset as it will result in duplicate import exceptions."
This suggests that both mapping are valid.
The problem is:
When specifying a <jdbcconfiguration .. configurationfile="hibernate.cfg.xml"> the <mapping> tags defined in the hibernate.cfg.xml are ignored (however, using the "fileset" solution works).
This problem comes from the org.hibernate.cfg.JDBCMetaDataConfiguration class: the parseMappingElement(Element,String) method does not allow parsing mapping elements because ignoreconfigxmlmapppings is set to true.
In this case, hibernate tools logs the following message:
[hibernatetool] Oct 7, 2008 9:18:27 AM org.hibernate.cfg.JDBCMetaDataConfiguration parseMappingElement
[hibernatetool] INFO: Ignoring null mapping
The message "Ignoring null mapping" (where null is the <session-factory> name property) is not very useful.
Things to be corrected:
1) in org.hibernate.cfg.JDBCMetaDataConfiguration, the log message
log.info("Ignoring "+name+" mapping");
should be replaced by
log.info("Ignoring session-factory "+(name!=null?name+" ":"")+"mapping: "+subelement.asXML()+" (jdbcconfiguration tags does not support mapping in the hibernate.cfg.xml file. Please use ant fileset instead)");
2) the JDBC configuration documentation should state that mappings in the hibernate.cfg.xml file are ignored.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-3734) Distributed QueryCache does not evict - UpdateTimestampsCache has null entry
by Eric Ellis (JIRA)
Distributed QueryCache does not evict - UpdateTimestampsCache has null entry
----------------------------------------------------------------------------
Key: HHH-3734
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3734
Project: Hibernate Core
Issue Type: Improvement
Components: caching (L2)
Affects Versions: 3.3.1
Environment: Centos 64, Hibernate 3.3.1 + ehcache1.5, multiple Tomcat virtual hosts - CMS app interacting with user facing app (high volume)
Reporter: Eric Ellis
Priority: Minor
Attachments: hibernate-core.patch
I've attached a patch that resolves the following distributed caching issue:
-App1 (user facing website)
-App2 (cms)
1. App1 calls: StandardQueryCache.cacheRegion.put() placing an HQL query in cache referencing table "A"
2. App2 makes an update to the entity representing table "A"
3. EHCache on App2 broadcasts an "UPDATE" message to update the UpdateTimestampsCache for table "A"
4. App1 receives the "UPDATE" message from App2 but ignores it because the UpdateTimestampsCache for App1 does not contain an entry for table "A"
5. App1 holds onto it's originally cached value and does not reflect the update that has taken place
Basically, the user facing application is not receiving CMS updates for HQL queries when distributed. This is because the QueryCache API does not pass the Set of "spaces" and the StandardQueryCache does not populate the UpdateTimestampsCache with an initial entry when an HQL query is cached.
The attached patch resolves this issue by simply adding an old (before now) timestamp to the UpdateTimestampsCache for each "space", if null, when a query is cached.
This code is currently running on a production cluster of 7, 8-CPU machines and is working perfectly. The downside is that now that the cache is evicting HQL queries we're finding that we have problems with how often our caches are being evicted. But at least now the data is correct.
Because this patch introduces an API change to QueryCache I don't expect that the fix will be accepted.
NOTE: I did not attempt to address the suggested locking issues
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months