[Hibernate-JIRA] Created: (HHH-3692) Inheritance Mapping in "table per class hierarchy": Allow for inheriting of properties from abstract classes above abstract class where table is defined
by Bradley Wagner (JIRA)
Inheritance Mapping in "table per class hierarchy": Allow for inheriting of properties from abstract classes above abstract class where table is defined
--------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3692
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3692
Project: Hibernate Core
Issue Type: Improvement
Affects Versions: 3.2.6
Reporter: Bradley Wagner
I'm basically using a "table per class hierarchy" mapping approach for a particular subset of my domain objects.
The issue is that I'd like to inherit a number of properties in my class that defines the table from some other base classes above it.
<union-subclass name="Template" abstract="true" table="template" extends="NamedObject">
.... template properties ...
</class>
<subclass name="SiteTemplate" discriminitator-value="ST" extends="Template">
.... site template properties ....
</subclass>
<subclass name="GlobalTemplate" discriminitator-value="GT" extends="Template">
.... global template properties ....
</subclass>
<class name="BaseObject" abstract="true">
<id name="id" type="string" unsaved-value="null'/>
</class>
<union-subclass name="NamedObject" abstract="true" extends="BaseObject">
<property name="name"/>
<property name="path"/>
</union-subclass>
The problem is that it's not possible for Template to extend NamedObject AND define a table and I'd prefer not to have to remap all of these properties that already exist in other mappings for other parts of my object hierarchy.
--
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-1952) HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952?page=c... ]
Steve Ebersole commented on HHH-1952:
-------------------------------------
Actually, is this still an issue? I am not seeing this behavior at all.
> HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: Hibernate: 3.1.3
> Reporter: David Donn
>
> If I have m mapped entities that implement the same interface and execute a polymorphic query with setMaxResults(n) I get n x m rows instead of n rows in my result.
> Query:
> session.createQuery("from Animal").setMaxResults(1)
> Hibernate mapping:
> <class
> name="Lion"
> table="lion" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
>
> <class
> name="Tiger"
> table="tiger" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
> Class definitions:
> public interface Animal {
> }
> public class Lion implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> public class Tiger implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> SQL:
> create sequence animal_seq start with 1
> /
> create table lion (id number(12) primary key)
> /
> create table tiger (id number(12) primary key)
> /
> insert into lion values (animal_seq.nextval)
> /
> insert into tiger values (animal_seq.nextval)
> /
--
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-1952) HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952?page=c... ]
Steve Ebersole commented on HHH-1952:
-------------------------------------
And what would you like to see? Since Hibernate fires off the "concrete queries" one-by-one, we cannot rely on simply passing setMaxResults through to the JDBC driver here.
The only solutions I see are:
1) Disallow setMaxResults in combo with implicit polymorphism queries;
2) Apply the setMaxResults in memory
> HQL query that uses implicit polymorphism returns (# concrete classes x n) rows, not n rows, when setMaxResults(n) is used
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1952
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: Hibernate: 3.1.3
> Reporter: David Donn
>
> If I have m mapped entities that implement the same interface and execute a polymorphic query with setMaxResults(n) I get n x m rows instead of n rows in my result.
> Query:
> session.createQuery("from Animal").setMaxResults(1)
> Hibernate mapping:
> <class
> name="Lion"
> table="lion" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
>
> <class
> name="Tiger"
> table="tiger" lazy="false">
>
> <id name="id">
> <generator class="sequence">
> <param name="sequence">animal_seq</param>
> </generator>
> </id>
>
> </class>
> Class definitions:
> public interface Animal {
> }
> public class Lion implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> public class Tiger implements Animal {
> private Long id;
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
>
> }
> SQL:
> create sequence animal_seq start with 1
> /
> create table lion (id number(12) primary key)
> /
> create table tiger (id number(12) primary key)
> /
> insert into lion values (animal_seq.nextval)
> /
> insert into tiger values (animal_seq.nextval)
> /
--
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-817) Aggregate projection aliases should not be applied to where-clause
by Danny Hurlburt (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-817?page=co... ]
Danny Hurlburt commented on HHH-817:
------------------------------------
I am having the same problem with SQL Server 2005. Aliases in the where clause can't be used. I am using criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP) so my aliases are the map's keys. I want the map's keys to be the same as the property names and therefore I have aliases that are the same as the property names. Of course when I add restrictions, I am using property names and this is causing aliases in the where clause.
This bug was reported about 3 1/2 YEARS ago. Why hasn't Hibernate fixed this bug?
If some databases can handle aliases in the where clause and some can't then the dialects should be updated and the where clause should be created accordingly.
> Aggregate projection aliases should not be applied to where-clause
> ------------------------------------------------------------------
>
> Key: HHH-817
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Oracle 9.2.0.6, Hibernate 3.0.5, Spring Framework 1.2.2 based application working on Jakarta Tomcat 5.0.28
> Reporter: Michal Jastak
> Priority: Minor
> Attachments: HHH-817.patch
>
>
> following java code:
> protected Entity loadEntityLightweight(Serializable entityId) throws DataAccessException {
> Criteria criteria = getSession().createCriteria(Entity.class);
> ProjectionList projectionList = Projections.projectionList();
> projectionList.add(Property.forName(BaseEntity.PROP_ID), BaseEntity.PROP_ID);
> projectionList.add(Property.forName(BaseEntity.PROP_TYPE), BaseEntity.PROP_TYPE);
> criteria.setProjection(projectionList);
> criteria.add(Restrictions.eq(BaseEntity.PROP_ID, entityId));
> criteria.setResultTransformer(new AliasToBeanResultTransformer(Entity.class));
> return (Entity) criteria.uniqueResult();
> }
> generates following SQL query:
> select this_.id as y0_, this_.type as y1_ from entities this_ left outer join facilities this_1_ on this_.id=this_1_.id left outer join users this_2_ on this_.id=this_2_.id left outer join addresses address2_ on this_.address_id=address2_.id left outer join entities entity3_ on this_2_.employer_id=entity3_.id left outer join facilities entity3_1_ on entity3_.id=entity3_1_.id left outer join users entity3_2_ on entity3_.id=entity3_2_.id where y0_=?
> y0_ = ? expression in where clause is causing a 904 error on Oracle 9:
> ORA-00904: "Y0_": invalid identifier
> hibernate dialect: org.hibernate.dialect.Oracle9Dialect
> mapping for Entity class:
> <?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 default-lazy="false" default-cascade="save-update">
>
> <class name="Entity" table="entities" mutable="true">
> <id name="id" type="java.lang.Long" unsaved-value="null">
> <generator class="sequence">
> <param name="sequence">entities_id_seq</param>
> </generator>
> </id>
> <many-to-one name="address" class="Address" column="address_id" />
> ...
> <!--
> - Facilities
> -->
> <joined-subclass name="Facility" table="facilities">
> <key column="id" />
> ...
> <set name="users" inverse="true" lazy="true">
> <key column="facility_id" />
> <one-to-many class="User" />
> </set>
> </joined-subclass>
> <!--
> - Users
> -->
> <joined-subclass name="User" table="users" dynamic-insert="true" dynamic-update="true">
> <key column="id" />
> <many-to-one name="employer" class="Entity" column="employer_id" cascade="none" />
> ...
> <set name="userAuthorities" inverse="true" cascade="all-delete-orphan">
> <key column="user_id" />
> <one-to-many class="Authority" />
> </set>
> </joined-subclass>
> </class>
> </hibernate-mapping>
--
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