[Hibernate-JIRA] Created: (ANN-436) @IndexColumn does not work with discriminator-inheritance on the target entity of the list
by ron piterman (JIRA)
@IndexColumn does not work with discriminator-inheritance on the target entity of the list
------------------------------------------------------------------------------------------
Key: ANN-436
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-436
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.0.cr1
Reporter: ron piterman
When using inheritance on the target entity of a List, @IndexColumn annotation does not work. Hibernate does not populate the index column value on the target entites. As a result, the sort_order column is null.
@Entity
public class PropertyOwner {
@OneToMany
@IndexColumn(name="sort_order", mappedBy="owner",cascade=CascadeType.ALL)
private List<AbstractProperty> properties;
...
}
@Entity
@DiscriminatorColumn(name="property_type",discriminatorType=DiscriminatorType.STRING)
public abstract class AbstractProperty {
@ManyToOne
private PropertyOwner owner;
}
@Entity
@DiscriminatorValue("integer")
public class IntegerProperty extends AbstractProperty {
int integerValue;
...
}
@Entity
@DiscriminatorValue("string")
public class IntegerProperty extends AbstractProperty {
String stringValue
...
}
--
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, 10 months
[Hibernate-JIRA] Created: (ANN-513) Multiple class validators of the same annotationtype
by Edwin van der Elst (JIRA)
Multiple class validators of the same annotationtype
----------------------------------------------------
Key: ANN-513
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-513
Project: Hibernate Annotations
Type: Improvement
Components: validator
Versions: 3.2.1
Reporter: Edwin van der Elst
Priority: Minor
I have a suggestion for the following problem:
I created an Validator to check if a 'date'> 'another date'
The annotation looks like this:
@After(property="endDate", after="beginDate", message="End should be after begin")
Since it involves 2 properties, it is a class-level validation.
Now....
I want multiple 'after' validations on a single bean.
But that is not possible (you can only place an annotation once on a class).
My proposal is to add an annotation 'Validations':
@Validations( {@After(...), @After(..)} )
I could do the multiple validations in a single validatorclass, but I want all the messages added to the invalidValues array, not a single message.
This change would also require changes in the ClassValidator class.
What do you think of this proposal? Should I add it to Jira (I can propably implement it if there are no objections to the required changes)
--
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, 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
18 years, 10 months