[Hibernate-JIRA] Created: (HHH-2432) Collection Mapping via "property-ref" on non-pk-column crashes
by Stefan Krinkel (JIRA)
Collection Mapping via "property-ref" on non-pk-column crashes
--------------------------------------------------------------
Key: HHH-2432
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2432
Project: Hibernate3
Type: Bug
Components: core
Environment: 3.2.2, Sybase DB
Reporter: Stefan Krinkel
Hi,
when using the following example, Hibernate attempts to pull a "getTownId()" on an Integer!
2 Tables, Village and Councillor. Village has a comp. ID (TownId, VillageId), Councillor uses
just the TownId-Part. To accomplish that, TOWN_ID is mapped twice (first in comp.key, second
as "townCode"), to be able to do a 'property-ref'.
When doing an ordinary "village.getCouncillors()" there's an IllegalArgumentException which
roots to BasicPropertyAccessor.java:145
public Object get(Object target) throws HibernateException {
try {
return method.invoke(target, null);
}
Here target is (Integer) townId and method is "VillageId.getTownId".
<id name="id" type="integer">
<column name="COUNCILLOR_ID" />
<generator class="identity"/>
</id>
<property name="TOWN" type="integer" >
<column name="TOWN_ID" not-null="true" />
</property>
==============================================
<composite-id name="VillageId" class="Table1Id">
<key-property name="townId" type="integer">
<column name="TOWN_ID" />
</key-property>
<key-property name="villageId" type="integer">
<column name="VILLAGE_ID" />
</key-property>
</composite-id>
<property name="townCode" type="integer" insert="false" update="false">
<column name="TOWN_ID" />
</property>
<bag name="councillors" outer-join="false" inverse="false" >
<key property-ref="townCode">
<column name="TOWN_ID" not-null="true" />
</key>
<one-to-many class="COUNCILLOR" />
</bag>
Needless to say, it's a legacy database, so wildly changing tables is out of question for me, it has to
work with hibernate.
Thanks
--
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
18 years
[Hibernate-JIRA] Created: (HHH-2699) Workaround for bug in PostgreSQL JDBC driver
by Matt Solnit (JIRA)
Workaround for bug in PostgreSQL JDBC driver
--------------------------------------------
Key: HHH-2699
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2699
Project: Hibernate3
Issue Type: Improvement
Affects Versions: 3.2.3
Environment: Hibernate 3.2.3, PostgreSQL 8.2.4 (Mac OS X), JDBC driver 8.2 Build 505 (JDBC 3)
Reporter: Matt Solnit
The following line (103) in org/hibernate/connection/DriverManagerConnectionProvider.java:
if (isolation!=null) pooled.setTransactionIsolation( isolation.intValue() );
causes an exception when using the PostgreSQL JDBC driver, because it does not allow you to change the transaction isolation level once a connection is in use. However, their implementation does not handle the fact that the isolation level is really not being changed in this case (because it is being set to the existing value).
The following change would work around this issue:
if ( isolation!=null && pooled.getTransactionIsolation()!=isolation.intValue() ) pooled.setTransactionIsolation( isolation.intValue() );
P.S. I know the DriverManagerConnectionProvider is not for production use, but we use it in development :-).
--
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
18 years
[Hibernate-JIRA] Created: (HHH-2353) ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
by James Andrews (JIRA)
ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
-----------------------------------------------------------------------
Key: HHH-2353
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2353
Project: Hibernate3
Type: Bug
Versions: 3.2.1, 3.2.0.cr4
Environment: Currently Hibernate 3.2.1, MySQL 5.0.26, Tomcat 5.5.20, Java 1.5 patch 10
Reporter: James Andrews
Above error thrown when attempting to force a left join fetch in hql on a many-to-many mapping:
Using 3 tables
accountgroup
id INTEGER PRIMARY
...
accountline
id INTEGER PRIMARY
...
accountgroupmapping
id INTEGER PRIMARY
groupId INTEGER
lineId INTEGER
...
Set mapping in hbm:
<set name="lines" table="budget.grouplinemap" fetch="join" lazy="false">
<key column="groupId" not-null="true"></key>
<many-to-many class="intranet.budget.AccountLine"
column="lineId" fetch="join" lazy="false">
</many-to-many>
</set>
HQL query executed:
select group from AccountGroup group left join fetch group.lines
Result:
java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:722)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1105)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:4920)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1066)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3198)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
The above works fine if I remove the left join fetch, or if I make the relationship one-to-many, but when I create a many-to-many relationship the error above occurs.
But since the above is being encoded to an AJAX frontend, and the lines fields are referenced immediately, removing the left join fetch results in N+1 selects despite the fetch="join" and lazy="false" in the .hbm descriptor.
--
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
18 years