Hibernate version: v3
Name and version of the database you are using: PostgreSQL v8.2
Hi,
I'm using JPA and Hibernate. I have 2 applications.
The first application generate some data, and store into the PostgreSQL database. It works fine. And if i do some requests in the DB, it works fine too.
Now, i have a second application. This one, do some requests on the object that have been store in the DB by the first application.
The problem is, when i do some request on objects that they have been store by another application, it don't work. I have some exception.
I don't understand why. Someone could explain me how to make this work ?
My persistence.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="Stockholm" transaction-type="RESOURCE_LOCAL">
<!-- provider -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!-- Classes persistantes -->
<property name="hibernate.archive.autodetection" value="class, hbm" />
<!-- logs SQL-->
<!-- <property name="hibernate.show_sql" value="true"/>-->
<!-- <property name="hibernate.format_sql" value="true"/>-->
<!-- <property name="use_sql_comments" value="true"/>-->
<!-- -->
<!-- connexion JDBC -->
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<property name="hibernate.connection.url" value="jdbc:postgresql:Stockholm" />
<property name="hibernate.connection.username" value="login" />
<property name="hibernate.connection.password" value="pwd" />
<!-- création automatique du schéma -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<!-- Dialecte -->
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<!-- propriétés DataSource c3p0 -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
</properties>
</persistence-unit>
</persistence>
My entityManagerCreation:
Code:
private static EntityManagerFactory emf = Persistence
.createEntityManagerFactory("Stockholm");
And my entities objects:
Code:
@SuppressWarnings("unused")
@Entity
@Table(name="BIMOBJ")
public class BimObj {
@Id
@Column(name = "BIM_ID", nullable = false)
private Integer bim_id;
@Column(name = "VERSION", nullable = false)
@Version
private int version;
@Column(name = "ref", length = 30, nullable = true, unique = true)
private String ref = null;
public BimObj(){
}
public BimObj(int id, String ref){
this.bim_id = id;
this.ref = ref;
}
....
}
@SuppressWarnings("unused")
@Entity
@Table(name="BimData")
public class BimData {
@Id
@Column(name = "BIMDATA_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer bimData_id;
@Column(name="TIME", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date horodate = null;
@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name = "BIM_ID", unique = false, nullable = false)
private BimObj bimObj;
public BimData(BimObj b, Date t{
this.bimObj = b;
this.horodate = t;
}
....
}
And here is my exception when i'm trying to work with the object store in the db my the other appli:
Code:
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: org.hibernate.InstantiationException: No default constructor for entity: common.BimObj
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
at modele.AccessDB.getAllBimObj(AccessDB.java:326)
at modele.Gestion.getAllBimObj(Gestion.java:72)
at vue.SSYClientMainFrame.actionPerformed(SSYClientMainFrame.java:255)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: org.hibernate.InstantiationException: No default constructor for entity: common.BimObj
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:84)
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:100)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:351)
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3539)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275)
at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1264)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1290)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
... 28 more