[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, 1 month
[Hibernate-JIRA] Created: (HHH-3923) Enver throws Nullpointer exception with a self reference entities
by Tahseen Ur Rehman (JIRA)
Enver throws Nullpointer exception with a self reference entities
-----------------------------------------------------------------
Key: HHH-3923
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3923
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: Hibernate Version: 3.3.1.GA
Database: Mysql 5.0
Reporter: Tahseen Ur Rehman
Priority: Blocker
@Entity(name = "category")
@Audited
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String name;
@ManyToOne
private Category parent;
@OneToMany(mappedBy = "parent")
private List<Category> childerns = new ArrayList<Category>();
....
}
Exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.carbonetworks.footprint.Footprint.initHibernate(Footprint.java:125)
at com.carbonetworks.footprint.Footprint.init(Footprint.java:73)
at com.carbonetworks.footprint.Main.main(Main.java:36)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: footprint] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
at com.carbonetworks.footprint.Footprint.initHibernate(Footprint.java:109)
... 2 more
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 6 more
Caused by: java.lang.NullPointerException
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:164)
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:150)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:141)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:161)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:385)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:96)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:249)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 10 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, 1 month
[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, 1 month
[Hibernate-JIRA] Commented: (HHH-1483) MySQL5: No Dialect mapping for JDBC type: -1
by Lars Michele (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483?page=c... ]
Lars Michele commented on HHH-1483:
-----------------------------------
Hi Gail,
I don't see the necessity for a testcase. Even if the problem occurs with MySQL, it is not MySQL specific.
A look in Dialect.java shows, what for HibernateTypes are registered:
// register hibernate types for default use in scalar sqlquery type auto detection
registerHibernateType maps java.sql.types to HibernateTypes, but some are missing, what generates the No Dialect mapping for JDBC type exception.
The missing java.sql.types are
ARRAY, BOOLEAN, DATALINK, DISTINCT, JAVA_OBJECT, LONGVARBINARY, LONGVARCHAR, NULL, OTHER, REF and STRUCT.
So whenever a native query returns some of these types, an exception is thrown.
Mappable to Hibernate are the following:
registerHibernateType( Types.LONGVARBINARY, Hibernate.BLOB.getName() );
registerHibernateType( Types.LONGVARCHAR, Hibernate.TEXT.getName() );
registerHibernateType( Types.BOOLEAN, Hibernate.BOOLEAN.getName() );
Related issues:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1806
got fixed in the same manner and fixed also (even if not remarked):
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1468
Have a nice weekend,
Lars
> MySQL5: No Dialect mapping for JDBC type: -1
> --------------------------------------------
>
> Key: HHH-1483
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: MySQL 5.0.18-nt
> Reporter: Sergey Vladimirov
> Priority: Minor
> Attachments: hhh-1483-patch.txt
>
>
> MySQL5: No Dialect mapping for JDBC type: -1
> SELECT answpos,answer FROM votes_answers WHERE question=? ORDER BY answpos
> mysql> describe votes_answers;
> +----------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+---------+------+-----+---------+-------+
> | question | int(11) | NO | MUL | | |
> | answpos | int(11) | NO | | | |
> | answer | text | YES | | NULL | |
> +----------+---------+------+-----+---------+-------+
> mysql> describe temp;
> +---------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+---------+------+-----+---------+-------+
> | answpos | int(11) | NO | | 0 | |
> | answer | text | YES | | NULL | |
> +---------+---------+------+-----+---------+-------+
> Please, let me know what to add to MySQL5Dialect :)
> Will it be ok to add? :
> registerColumnType( Types.LONGVARCHAR, "text" );
--
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, 1 month