[Hibernate-JIRA] Created: (HHH-3537) Criteria Projections does not work on type level
by Hauke Rabe (JIRA)
Criteria Projections does not work on type level
------------------------------------------------
Key: HHH-3537
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3537
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.3.1
Reporter: Hauke Rabe
A criteria without a user specific projection adds all object properties to the select fragment and backwards. These functionallity is missing on user specific projections. I want to declare a projection on a type level. See the projection Projections.object("aliasA") in following example:
Criteria criteriaA = session.createCriteria("A", "aliasA");
Criteria criteriaB = criteriaA.createCriteria("B", "aliasB")
// some criterion on A and B
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.object("aliasA"));
projectionList.add(Projections.max("aliasB.xxx"));
criteria.setProjection(projectionList);
In deep:
org.hibernate.loader.Loader.getRowFromResultSet(...) has the functionallity to instantiate objects from the result set if entitity persisters are set, these entity persisters are set through the org.hibernate.loader.JoinWoker.initPersisters(...) only if no user specific projection is set.
--
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
17 years, 6 months
[Hibernate-JIRA] Commented: (HHH-1523) LazyInitializationError on enabling query cache...
by John Reiter (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1523?page=c... ]
John Reiter commented on HHH-1523:
----------------------------------
This is still a problem using Hibernate 3.3.1 GA. Very frustrating.
> LazyInitializationError on enabling query cache...
> --------------------------------------------------
>
> Key: HHH-1523
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1523
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1
> Environment: 3.0.1 and 3.1, HSQLDB and Oracle
> Reporter: Vikas Sasidharan
> Attachments: cache_issue.log, QueryCacheIssue.zip
>
>
> I have two domain objects - Employee and Department - and there is a 1:N relationship from Department to Employee. When I join fetch an Employee with its Department, without query cache enabled, it works fine. If I enable query cache for this same query, it bombs with a LazyInitializationException.
> Notes:
> 1) We get this error only if query cache is enabled.
> 2) We observed the same behaviour on both oscache and ehcache
> 3) Calling Hibernate.initialize() explicitly after firing the HQL seems to work. The initialization does not fire an extra query though (it seems to pick it from the cache).
> 4) Setting "lazy=false" on the "many-to-one" mapping also works. However, it wouldn't be acceptable.
> Hibernate version: 3.0.5
> Mapping documents:
> Employee.hbm.xml
> <hibernate-mapping>
> <class name="tavant.platform.test.domain.Employee"
> table="CACHE_ISSUE_EMP" lazy="true" dynamic-update="true" dynamic-insert="true">
> <cache usage="read-write" />
> <id name="id" column="EMP_ID" type="java.lang.Long"
> access="field" unsaved-value="null">
> <generator class="increment" />
> </id>
>
> <property name="name" type="string" update="true"
> insert="true" column="EMP_NAME"/>
> <many-to-one name="department" class="tavant.platform.test.domain.Department"
> cascade="none" outer-join="auto" update="true" insert="true" column="DEPARTMENT_ID"/>
> </class>
> </hibernate-mapping>
>
> Department.hbm.xml
> <hibernate-mapping>
> <class name="tavant.platform.test.domain.Department" table="CACHE_ISSUE_DEP"
> lazy="true" dynamic-update="true" dynamic-insert="true">
>
> <cache usage="read-write" />
> <id name="id" column="DEPARTMENT_ID"
> type="java.lang.Long" access="field">
> <generator class="increment"/>
> </id>
> <property name="name" type="java.lang.String"
> update="false" insert="true" column="NAME"/>
> <bag name="employees" lazy="true"
> inverse="true" cascade="save-update" access="field">
> <cache usage="read-write"/>
> <key column="DEPARTMENT_ID"/>
> <one-to-many class="tavant.platform.test.domain.Employee"/>
> </bag>
> </class>
> </hibernate-mapping>
>
> Code between sessionFactory.openSession() and session.close():
> public Employee getEmployeeWithDepartment(String empName) {
> Session session = null;
> try {
> session = sessionFactory.openSession();
> Employee emp = (Employee) session.createQuery(
> "from Employee e join fetch e.department where e.name = :name")
> .setString("name", empName)
> .setCacheable(true)
> .uniqueResult();
> // If I uncomment the next line, this works (even without
> // firing an extra query)!
> // Hibernate.initialize(emp.getDepartment());
> return emp;
> } finally {
> if (session != null) {
> session.close();
> }
> }
> }
>
> // First load employee and populate cahces
> Employee emp = test.getEmployeeWithDepartment(EMPLOYEE_NAME);
> System.out.println("Employee : " + emp + ", Employee.Department : "
> + emp.getDepartment());
>
> // Now try to make use of the cache
> emp = test.getEmployeeWithDepartment(EMPLOYEE_NAME);
> System.out.println("Employee : " + emp + ", Employee.Department : "
> + emp.getDepartment());
>
> Full stack trace of any exception that occurs:
> org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
> at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
> at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
> at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
> at tavant.platform.test.domain.Department$$EnhancerByCGLIB$$67b26899.toString(<generated>)
> at java.lang.String.valueOf(String.java:2131)
> at java.lang.StringBuffer.append(StringBuffer.java:370)
> at tavant.platform.test.client.TestPrefetchRelationWithQueryCacheEnabled.main(TestPrefetchRelationWithQueryCacheEnabled.java:116)
>
> Name and version of the database you are using:
> We have noticed this on Oracle and HSQL
> The generated SQL (show_sql=true):
> #First read, goes fine
> Hibernate: select employee0_.EMP_ID as EMP1_0_, department1_.DEPARTMENT_ID as DEPARTMENT1_1_, employee0_.EMP_NAME as EMP2_1_0_, employee0_.DEPARTMENT_ID as DEPARTMENT3_1_0_, department1_.NAME as NAME0_1_ from CACHE_ISSUE_EMP employee0_ inner join CACHE_ISSUE_DEP department1_ on employee0_.DEPARTMENT_ID=department1_.DEPARTMENT_ID where (employee0_.EMP_NAME=? )
> #Prints the Employee and Department fine
> Employee : [Id : 1, name : testEmployee], Employee.Department : [Id : 1, name : testDepartment]
> #Second read bombs!
> org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
> at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
> at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
> at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
> [..]
> Please have a look at the post [http://forum.hibernate.org/viewtopic.php?t=955839] for more details and follow ups.
> Kindly help. I am attaching an Eclipse Project containing the TestCase. The main file is TestPrefetchRelationWithQueryCacheEnabled.
> Thanks,
> Vikas
--
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
17 years, 6 months
[Hibernate-JIRA] Created: (HHH-3534) Subqueries with DetachedCriteria use erroneous alias since version 3.2.6.ga
by Eirik Maus (JIRA)
Subqueries with DetachedCriteria use erroneous alias since version 3.2.6.ga
---------------------------------------------------------------------------
Key: HHH-3534
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3534
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.3.1, 3.3.0.GA, 3.2.6
Environment: Hibernate versions 3.2.6, 3.3.0.GA, 3.3.1.GA.
Databases Hsql 1.8.0.1 and H2 1.1.100 both in in-memory mode.
H2 and HSQL sql dialects.
Sun JDK 1.6.0 (several versions), both Linux and Windows OS.
Reporter: Eirik Maus
When creating a query with a sub-query based on a DetachedCriteria, like in Don Mitchels comment of 2007-05-15 to issue HHH-952, default alias (using the single-parameter factory method of DetachedCriteria) for the detached criteria object will be the same as the alias for the root object of the root criteria ("this_"). This obviously cannot work as expected.
The error was introduced in Hibernate 3.2.6.ga. Versions 3.2.4 and 3.2.5 does not have this problem.
A workaround is to specify an alias different than "this_" (and any other expected query alias) for the DetachedCriteria. As a consequence, the method DetachedCriteria.forClass(SomeClass.class) cannot be used at all since version 3.2.6.ga. An alias must be specified (and it must be different from "this_" ).
A solution would make the DetachedCriteria cooperate with its root Criteria to find an unused alias name. Typically, the query for the main Criteria will already use some aliases based on the same table in eager-loaded joins, so some form of cooperation or subquery alias prefix scheme must be used.
--
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
17 years, 6 months
[Hibernate-JIRA] Created: (HHH-3533) Duplicated columns in gen. sql(superfluous data transfer)
by Igors Sakels (JIRA)
Duplicated columns in gen. sql(superfluous data transfer)
---------------------------------------------------------
Key: HHH-3533
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3533
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Environment: Hibernate version:
3.3.1
Name and version of the database you are using:
Oracle 9i
Reporter: Igors Sakels
Priority: Minor
Mapping documents:
@Entity
@org.hibernate.annotations.Entity(mutable = false)
@Table(name = "demo_tmp_fin_header")
public class TmpFinHeader {
@Id
@Column(name = "edw_doc_id")
private String edwDocId;
@Column(name = "period")
private Date period;
@OneToMany
@JoinColumn(name = "edw_doc_id")
@org.hibernate.annotations.BatchSize(size = 100)
private Set<TmpFinData> tmpFinDataSet = new HashSet<TmpFinData>();
// getters, setters
}
@Entity
@org.hibernate.annotations.Entity(mutable = false)
@Table(name = "demo_tmp_fin_data")
public class TmpFinData {
@EmbeddedId
private TmpFinDataId tmpFinDataId;
@Column(name = "amount")
private BigDecimal amount;
// getters, setters
}
@Embeddable
public class TmpFinDataId implements Serializable {
@Column(name = "edw_doc_id")
private String edwDocId;
@Column(name = "amount_id")
private String amountId;
// getters, setters, equals, hashCode
}
Code between sessionFactory.openSession() and session.close():
TmpFinHeader header = hibernateTemplate.get(TmpFinHeader.class, 1);
header.getTmpFinDataSet().size();
The generated SQL (show_sql=true):
select
tmpfindata0_.edw_doc_id as edw2_1_,
tmpfindata0_.amount_id as amount1_1_,
tmpfindata0_.amount_id as amount1_1_0_,
tmpfindata0_.edw_doc_id as edw2_1_0_,
tmpfindata0_.amount as amount1_0_
from
gl_loan.demo_tmp_fin_data tmpfindata0_
where
tmpfindata0_.edw_doc_id=?
--
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
17 years, 6 months
[Hibernate-JIRA] Created: (HHH-3487) DefaultLoadEventListener does not honor lazy load (LoadEventListener.LoadType.INTERNAL_LOAD_LAZY)
by Will Hoover (JIRA)
DefaultLoadEventListener does not honor lazy load (LoadEventListener.LoadType.INTERNAL_LOAD_LAZY)
-------------------------------------------------------------------------------------------------
Key: HHH-3487
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3487
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: N/A
Reporter: Will Hoover
Priority: Critical
DefaultLoadEventListener#doLoad(...) and DefaultLoadEventListener#loadFromDatasource(...) does not honor LoadEventListener.LoadType.INTERNAL_LOAD_LAZY
USE CASE:
1) Create Actor table with self-referencing parent/child relationship with the following mapping- results in SessionImpl#internalLoad(...) setting LoadEventListener.LoadType to LoadEventListener.LoadType.INTERNAL_LOAD_LAZY:
<hibernate-mapping>
<class name="Actor" table="ACTOR">
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="actor" class="Actor" lazy="no-proxy">
<column name="PARENT_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<set name="actors" inverse="true" >
<key>
<column name="PARENT_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="Actor" />
</set>
</class>
</hibernate-mapping>
2) Add a parent/child relationship entries in database: ID:1,PARENT_ID:1 and ID:2,PARENT_ID:1
3) Issue "Actor actor = (Actor) session.get(Actor.class, 1L);"
Results: Hibernate.isPropertyInitialized(actor, "actor") == true
--
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
17 years, 6 months