[Hibernate-JIRA] Created: (HHH-2422) unexpected object loading with Mixing table per class hierarchy with table per subclass
by Paul Song (JIRA)
unexpected object loading with Mixing table per class hierarchy with table per subclass
---------------------------------------------------------------------------------------
Key: HHH-2422
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2422
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1, 3.2.0.cr4, 3.2.2, 3.2.0.ga, 3.2.0.cr5
Environment: Linux(Red Hat 4.0 AS) + JBOSS4.0.5.GA + Hibernate 3.2.2.GA + MySQL5.0.27 Community edition + JDK1.5_06
Reporter: Paul Song
Priority: Critical
Attachments: sourceCode.rar
3 entity classes: Token, AudioToken, Actor.
AudioToken is a subclass of Token, Token is a member variable of Actor.
That means Actor instance may have Token object or AudioToken object at runtime. The mapping definition of Token and Audio Token use Mixing table per class hierarchy with table per subclass. So the Audio Token has its own properties in a different sub table(AudioToken table) besides it has common properties in token table.
When loading actor, this actor will get its token object reference automatically according to mapping(lazy loading is false). Although the audio token object is returned, it did not contain information of sub table(i.e. serialNumber) but just that of parent table(i.e., id, type counter etc.)
The same exact code package is working well with following Environment:
1, Windows2003 + JBOSS4.0.5.GA + Hibernate 3.2.2.GA + MySQL5.0.27 Community edition + JDK1.5_06
2, Windows2003 + WebLogic(9.1, 9.2)+ Hibernate 3.2.2.GA + MySQL5.0.27 Community edition + JDK1.5_06
3,Linux(Redhat 4.0 AS) + WebLogic(9.1, 9.2)+ Hibernate 3.2.2.GA + MySQL5.0.27 Community edition + JDK1.5_06
Except above unexpected object return, When I use AudioTokenDao to get the object by PK, I can get the object containing information of both parent table and sub table. but If I use TokenDao to get the object by same PK, I can only get the object containing information of parent table(Token table). it's not expected this way but happened on environment of
Linux(Red Hat 4.0 AS) + JBOSS4.0.5.GA + Hibernate 3.2.2.GA + MySQL5.0.27 Community edition + JDK1.5_06
--
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, 10 months
[Hibernate-JIRA] Commented: (HHH-1005) Criteria LEFT JOIN capability when adding Order to associations
by DJ Gregor (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1005?page=c... ]
DJ Gregor commented on HHH-1005:
--------------------------------
Oleg,
Regarding your last comment, the issue HHH-879 is to "Enable joining the same association twice with Criteria".
> Criteria LEFT JOIN capability when adding Order to associations
> ---------------------------------------------------------------
>
> Key: HHH-1005
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1005
> Project: Hibernate3
> Type: Patch
> Components: query-criteria
> Versions: 3.1 rc3
> Reporter: Leonardo Quijano
> Assignee: Steve Ebersole
> Fix For: 3.1.2
> Attachments: CriteriaJoinTypes.patch
>
>
> As in:
> http://forum.hibernate.org/viewtopic.php?t=291&start=0&postdays=0&postord...
> A way of specifying a join mode for Criteria queries would be great, such as in:
> criteria.createCriteria("association", JoinFragment.LEFT_OUTER_JOIN)
> or a similar syntax.
> I think this is important because is counterintuitive that order clauses add a filter to a Criteria. I know that by default a subCriteria will put an INNER_JOIN, but then again, if I have a QBE in a page with no filters, and click on a column to sort by that, I should get the same number of results as if I clicked another column, right? I would set a LEFT JOIN as default to avoid problems like that.
> Since that would break functionality, of course, then at least an overloaded version of createCriteria would be possible? 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
17 years, 10 months
[Hibernate-JIRA] Created: (ANN-541) Bug Mixing Annotations with Mapping Files. (Minimal Test Case Attached)
by Adam T (JIRA)
Bug Mixing Annotations with Mapping Files. (Minimal Test Case Attached)
-----------------------------------------------------------------------
Key: ANN-541
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-541
Project: Hibernate Annotations
Type: Bug
Environment: Hibernate Annotations 3.2.1.GA
Hibernate 3.2.1
Reporter: Adam T
Attachments: HibernateMixedMappingsTestCase.zip
I have found a bug in Hibernate when mixing annotations and mapping files. I have generated a minimal test case. Additionally, I have confirmed that the error does not appear when all classes use annotations.
There are two mapped classes AImpl and BImpl. AImpl extends BImpl. A third annotated class ZImpl, refers to BImpl through a ManyToOne relationship. All method signatures refer to these classes by their interfaces A, B, and Z; however, Hibernate is instructed to use the *Impl classes when necessary.
I am NOT mixing annotations and mappings in a single inheritance hierarchy. All classes implement Serializable by extending their Serializable interfaces.
The minimal test case is attached as a zip and included below:
13:02:57,811 INFO [Version] Hibernate Annotations 3.2.1.GA
13:02:57,827 INFO [Environment] Hibernate 3.2.1
13:02:57,827 INFO [Environment] hibernate.properties not found
13:02:57,842 INFO [Environment] Bytecode provider name : cglib
13:02:57,842 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
13:02:57,936 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
13:02:57,936 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
13:02:58,077 INFO [Configuration] Reading mappings from resource : B.hbm.xml
13:02:58,342 INFO [Configuration] Reading mappings from resource : A.hbm.xml
13:02:58,389 INFO [Configuration] Configured SessionFactory: null
13:02:58,655 INFO [HbmBinder] Mapping class: test.AImpl -> A
13:02:58,670 INFO [AnnotationBinder] Binding entity from annotated class: test.ZImpl
13:02:58,702 INFO [EntityBinder] Bind entity test.ZImpl on table Z
13:02:58,780 ERROR [HibernateUtil] Building SessionFactory failed.
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on test.ZImpl.b references an unknown entity: test.BImpl
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at org.illumen.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:85)
at test.TestMixedMappings.main(TestMixedMappings.java:10)
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.illumen.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:93)
at test.TestMixedMappings.main(TestMixedMappings.java:10)
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on test.ZImpl.b references an unknown entity: test.BImpl
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at org.illumen.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:85)
... 1 more
hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:/comp/env/jdbc/newsoncongress</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<mapping resource="B.hbm.xml" />
<mapping resource="A.hbm.xml" />
<mapping class="test.ZImpl" />
</session-factory>
</hibernate-configuration>
A.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">
<!-- Generated Nov 9, 2006 6:27:53 PM by Hibernate Tools 3.2.0.beta7 -->
<hibernate-mapping>
<class name="test.AImpl" table="A" proxy="test.A">
<id name="aId" column="aID" type="java.lang.Integer">
<generator class="identity" />
</id>
</class>
</hibernate-mapping>
B.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">
<!-- Generated Nov 9, 2006 6:27:53 PM by Hibernate Tools 3.2.0.beta7 -->
<hibernate-mapping>
<joined-subclass name="test.BImpl" table="B" proxy="test.B"
extends="test.AImpl">
<key column="aID" />
<property name="bId" column="bID" type="java.lang.Integer"
not-null="true" />
</joined-subclass>
</hibernate-mapping>
A.java:
package test;
public interface A extends java.io.Serializable {
public Integer getAId();
public void setAId(Integer aId);
}
B.java:
package test;
public interface B extends A {
public Integer getBId();
public void setBId(Integer bId);
}
Z.java:
package test;
public interface Z extends java.io.Serializable {
public Integer getZId();
public void setZId(Integer zId);
public B getB();
public void setB(B b);
}
AImpl.java:
package test;
public class AImpl implements A {
private static final long serialVersionUID = 1L;
private Integer aId = 0;
public AImpl() {
}
public Integer getAId() {
return this.aId;
}
public void setAId(Integer aId) {
this.aId = aId;
}
}
BImpl.java:
package test;
public class BImpl extends AImpl implements B {
private static final long serialVersionUID = 1L;
private Integer bId = 0;
public BImpl() {
super();
}
public Integer getBId() {
return bId;
}
public void setBId(Integer bId) {
this.bId = bId;
}
}
ZImpl.java:
package test;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.Proxy(proxyClass = Z.class)
@Table(name = "Z")
public class ZImpl implements Z {
private static final long serialVersionUID = 1L;
private Integer zId = null;
private B b = null;
@Id
@Column(name = "zID")
public Integer getZId() {
return zId;
}
public void setZId(Integer zId) {
this.zId = zId;
}
@ManyToOne(optional = false, targetEntity = BImpl.class, fetch = FetchType.LAZY)
@JoinColumn(name = "bID", referencedColumnName = "bID")
public B getB() {
return b;
}
public void setB(B b) {
this.b = b;
}
}
...
When the AImpl and BImpl classes are annotated, the error disappears.
AImpl.java:
package test;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.Proxy(proxyClass = A.class)
@Table(name = "A")
public class AImpl implements A {
private static final long serialVersionUID = 1L;
private Integer aId = 0;
public AImpl() {
}
@Id
@Column(name = "aID")
public Integer getAId() {
return this.aId;
}
public void setAId(Integer aId) {
this.aId = aId;
}
}
BImpl.java:
package test;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@org.hibernate.annotations.Proxy(proxyClass = B.class)
@Table(name = "B")
public class BImpl extends AImpl implements B {
private static final long serialVersionUID = 1L;
private Integer bId = 0;
public BImpl() {
super();
}
public Integer getBId() {
return bId;
}
public void setBId(Integer bId) {
this.bId = bId;
}
}
That's all folks!
--
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, 10 months