[Hibernate-JIRA] Created: (HHH-2891) Query cache fails on many-to-many select
by Oleg Efimov (JIRA)
Query cache fails on many-to-many select
----------------------------------------
Key: HHH-2891
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2891
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Reporter: Oleg Efimov
I have two entities, User and Group, with many-to-many relation:
-------------------------------------------------------------------------------------------------- User.hbm.xml
<?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 package="test.hibernate">
<class name="User" table="`USER`">
<id name="id" type="long" unsaved-value="null">
<column name="USER_ID" not-null="true"/>
<generator class="native"/>
</id>
<property name="login">
<column name="LOGIN" not-null="true" length="255"/>
</property>
<bag name="groups" table="USER_GROUP" lazy="false" cascade="none">
<key column="USER_ID"/>
<many-to-many class="Group" column="GROUP_ID"/>
</bag>
</class>
</hibernate-mapping>
-------------------------------------------------------------------------------------------------- Group.hbm.xml
<?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 package="test.hibernate">
<class name="Group" table="`GROUP`">
<id name="id" type="long" unsaved-value="null">
<column name="GROUP_ID" not-null="true"/>
<generator class="native"/>
</id>
<property name="name">
<column name="GROUPNAME" not-null="true" length="100"/>
</property>
<bag name="users" table="USER_GROUP" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="GROUP_ID"/>
<many-to-many class="User" column="USER_ID"/>
</bag>
</class>
<query name="Group.select.by.login" cacheable="true"><![CDATA[
select user.groups from User user where user.login=?
]]>
</query>
</hibernate-mapping>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test.hibernate.User and test.hibernate.Group classes are just simple beans.
In Group.hbm.xml there is a query called "Group.select.by.login", it's intended to be cached. So I add corresponding properties to Hibernate configuraition:
--------------------------------------------------------------------------------------------------
properties.put("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
properties.put("hibernate.cache.use_query_cache", "true");
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Configuration has no extra parameters.
Then I'm trying to execute the query two times:
-------------------------------------------------------------------------------------------------- test fragment
SessionFactory sessionFactory = configuration.buildSessionFactory();
Session session = null;
try {
session = sessionFactory.openSession();
Query query = session.getNamedQuery("Group.select.by.login");
List<Group> groups;
groups = query.setParameter(0, "admin").list(); // +++++++++++++++This list() returns list of two Group objects, ok +++++++++++++++
System.out.println("-----------------------------------------------------------------------------------");
for (Group group : groups) {
System.out.println(group.getName());
}
System.out.println("-----------------------------------------------------------------------------------");
groups = query.setParameter(0, "admin").list(); // +++++++++++++++This list() returns list of two nulls +++++++++++++++
System.out.println("-----------------------------------------------------------------------------------");
for (Group group : groups) {
System.out.println(group.getName());
}
System.out.println("-----------------------------------------------------------------------------------");
} finally {
if (session != null) {
session.close();
}
sessionFactory.close();
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The first query returns list of, in my case, two groups. The second query returns list of two nulls instead of the same list.
I've investigated the problem, and found the following:
Query return value is "user.groups", and during query analysis (org.hibernate.hql.ast.QueryTranslatorImpl:160) query return type is defined as "org.hibernate.type.BagType(test.hibernate.User.groups)". This seems to be the problem, as during query put operation org.hibernate.CollectionType.disassemble is called (org.hibernate.cache.StandardQueryCache:80), which simply returns null as owner is null.
If this query is not a misuse, then I think, something is to be done at the time of analysis, so that return type be somewhat different.
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
12 years, 1 month
[Hibernate-JIRA] Created: (HHH-4732) Update Teradata Dialect for Teradata 13.0
by David Repshas (JIRA)
Update Teradata Dialect for Teradata 13.0
-----------------------------------------
Key: HHH-4732
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4732
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.3.2
Environment: Hibernate 3.3.2/ Teradata JDBC Driver 13.0, Teradata Database 13.0
Reporter: David Repshas
Attachments: teradata.zip
Would like to update Teradata Dialect to work with Teradata Database 13.0.
I've include the following files with changes as noted:
org.hibernate.dialect.dialect.java
- added include of java.sql.statement
- added code to support the removal of temporary
files created when using referential integrity
The three new methods are:
public boolean supportsDropPreProcess()
public String performDropPreProcess(Statement stmt, String dropSql) throws SQLException
public void performDropPostProcess(Statement stmt, String dropSql) throws SQLException
==================================
org.hibernate.dialect.TeradataDialect.java
- added new include files
- modified registerFunction calls for "current_time" and "current_date"
- put registerKeyword list in alphabetical order and added keywords:
column,map,password,summary, type, value and year
- changed "getAddColumnString()" to return "Add"
- added new methods:
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
public String extractConstraintName(SQLException sqlex)
public boolean supportsNotNullUnique()
public boolean supportsExpectedLobUsagePattern()
public boolean supportsUnboundedLobLocatorMaterialization()
public boolean supportsDropPreProcess()
public String performDropPreProcess(Statement stmt, String dropSql) throws SQLException
public void performDropPostProcess(Statement stmt, String dropSql) throws SQLException
==================================
org.hibernate.tool.hbm2ddl.SchemaExport
- added hooks for new methods:
supportsDropPreProcess,performDropPreProcess and performDropPostProcess
==================================
Also made some changes to some of the files in testsuite:
=============================================
test/hql/astParserLoadingTest.java
- Add instance check of TeradataDialect to get correct behavior
=============================================
test/legacy/foobartest.java
- Add instance check of TeradataDialect to get correct behavior
- modified SQL: Teradata requires "<>" rather than "!="
=============================================
test/typeParameters\typeparametertest.java
-needed to disable these tests as Teradata locking was causing
a deadlock situation when they run
=============================================
--
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
12 years, 1 month