[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
[Hibernate-JIRA] Created: (HHH-3847) java.lang.NullPointerException on onPreRemoveCollection on replicate of persistent class
by Francesco Di Salvatore (JIRA)
java.lang.NullPointerException on onPreRemoveCollection on replicate of persistent class
----------------------------------------------------------------------------------------
Key: HHH-3847
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3847
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: Envers 1.2, Hibernate 3.3.1 on Mysql and Hsql.
Reporter: Francesco Di Salvatore
Priority: Critical
Attachments: TestEnvers12.zip
I get this exception when trying to REPLICATE an object in a synchronized database:
Code:
DEBUG [main] (CodeSystemDAOHibernate.java:131) - java.lang.NullPointerException
at org.hibernate.envers.event.AuditEventListener.onPreRemoveCollection(AuditEventListener.java:235)
at org.hibernate.action.CollectionRemoveAction.preRemove(CollectionRemoveAction.java:134)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:100)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:169)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventLis
tener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.phi.dictionarymanager.logic.hibernate.GenericDAOHibaernate.commitNetwork(GenericDAOHibaernate
.java:183)
at com.phi.dictionarymanager.logic.hibernate.CodeSystemDAOHibernate.save(CodeSystemDAOHibernate.jav
a:92)
at com.phi.dictionarymanager.ui.widgets.VocabolaryItemNewComposite.save(VocabolaryItemNewComposite.
java:515)
at com.phi.dictionarymanager.ui.widgets.VocabularyDomainsNavigatorComposite$18.handleEvent(Vocabula
ryDomainsNavigatorComposite.java:1434)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.j
ava:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Code throwing the exception:
Code:
beginTransactionLocal();
makePersistentLocal(cs);
commitLocal();
closeSessionLocal();
beginTransactionNetwork();
makePersistentNetwork(cs);
commitNetwork();
closeSessionNetwork();
For this insertion of the object cs, the makePersistentLocal makes a saveOrUpdate call, while makePersistentNetwork calls replicate(cs, ReplicateMode.LATEST_VERSION).
My hibernate-mysql.cfg.xml and hibernate-hsql.cfg.xml are very similar (I post only the mysql one):
Code:
<hibernate-configuration>
<session-factory>
...
<property name="org.hibernate.envers.revisionOnCollectionChange">true</property>
<property name="org.hibernate.envers.doNotAuditOptimisticLockingField">true</property>
<!-- HIBERNATE BEAN MAPPINGS -->
<mapping resource="com/phi/dictionarymanager/beans/CodeEquivalent.hbm.xml" />
<mapping resource="com/phi/dictionarymanager/beans/CodeValue.hbm.xml" />
<mapping resource="com/phi/dictionarymanager/beans/CodeTranslation.hbm.xml" />
<mapping resource="com/phi/dictionarymanager/beans/CodeSystem.hbm.xml" />
<event type="post-insert">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-update">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-delete">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="pre-collection-update">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="pre-collection-remove">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-collection-recreate">
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
</session-factory>
</hibernate-configuration>
All the collections in this project are in mode lazy="true".
In the first saving the onPreRemoveCollection method is never called.
--
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