[Hibernate-JIRA] Created: (ANN-838) Can't override @GenericGenerator annotation from @MappedSuperclass
by Aliaksej Memelau (JIRA)
Can't override @GenericGenerator annotation from @MappedSuperclass
------------------------------------------------------------------
Key: ANN-838
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-838
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: JVM 1.6, Hibernate core 3.3.1.GA
Reporter: Aliaksej Memelau
Priority: Critical
I want to override @GenericGenerator in a subclass,
@MappedSuperclass
public class Entity {
@Id
@Column(name="ID")
@GeneratedValue(generator = "a_generator")
@GenericGenerator(
name = "a_generator",
strategy = "a_strategy"
)
private Long id;
...
}
but, the following code doesn't work
@Entity
@Table("A_TABLE")
@GenericGenerator(
name = "a_generator",
strategy = "a_strategy_2"
)
public class SubEntity extends Entity {...}
When I try to pull out @GenericGenerator annotation from Entity's id to the class level hibernate throws:
org.hibernate.AnnotationException: Unknown Id.generator: a_generator
I suppose the following code should work:
@MappedSuperclass
@GenericGenerator(
name = "a_generator",
strategy = "a_strategy"
)
public class Entity {
@Id
@Column(name="ID")
@GeneratedValue(generator = "a_generator")
private Long id;
...
}
@Entity
@Table("A_TABLE")
@GenericGenerator(
name = "a_generator",
strategy = "a_strategy_2"
)
public class SubEntity extends Entity {...}
--
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, 7 months
[Hibernate-JIRA] Created: (ANN-698) @Transient property leads to org.hibernate.AnnotationException: Property has an unbound type
by Sebastian Baltes (JIRA)
@Transient property leads to org.hibernate.AnnotationException: Property has an unbound type
--------------------------------------------------------------------------------------------
Key: ANN-698
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-698
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: hibernate3.jar: 3.2.5.ga
hibernate-annotations.jar: 3.3.0.GA
hibernate-commons-annotations.jar: 3.0.0.GA
hibernate-validator.jar: 3.0.0.GA
MySQL
Reporter: Sebastian Baltes
Attachments: log.txt
Transient fields are not ignored in Hibernate. I got an "Property has an unbound type" exception and found no workaround.
Entity:
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
@Entity
public class Dummy<K> {
@Id
private Long id;
@Transient
transient private K dummyField;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public K getDummyField() {
return dummyField;
}
public void setDummyField(K dummyField) {
this.dummyField = dummyField;
}
}
Test Code:
EntityManager em = EntityManagerSingleton.get();
EntityTransaction tx = em.getTransaction();
tx.begin();
Dummy a = new Dummy();
em.persist(a);
tx.commit();
Exception:
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at junit.framework.TestSuite.createTest(TestSuite.java:54)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
at junit.framework.TestSuite.<init>(TestSuite.java:140)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: javax.persistence.PersistenceException: org.hibernate.AnnotationException: Property de.neise.gena.model.file.Dummy.dummyField has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at de.neise.gena.model.testbase.BaseTest.<clinit>(BaseTest.java:19)
... 13 more
Caused by: org.hibernate.AnnotationException: Property de.neise.gena.model.file.Dummy.dummyField has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:993)
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:833)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:645)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 17 more
--
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, 7 months