Hibernate version:
3.2
Mapping documents:
Over Annotations
Full stack trace of any exception that occurs:
Caused by: org.hibernate.MappingException: Unknown entity: de.floe.timernx.plugin.AutoCal.AutoCalPlugin
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
Name and version of the database you are using:
MySQL 5.0
Hello,
I have a program that is extendable over plugins. The plugins take playe in a folder as JAR files and where loaded over the ServioceLoader mechanism from Java 6. Every plugin has his own package an contained a specific class (AustoCalPLugin) an inherit from a generell class (Plugin)
The PluginHandler schould save the inheritet Plugin object in the DB
PluginHandler.java:
Code:
public void add() {
ServiceLoader<Plugin> service = load();
while(service.iterator().hasNext()) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Plugin plugin = service.iterator().next();
session.save(plugin);
session.getTransaction().commit();
}
}
The Plugin object is an abstract class (Getter/Setter methods are cut for better viewing)
Plugin.java:Code:
@Entity
@Table(name="plugin")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Plugin implements Serializable{
@Id
private int id;
@Column(nullable=false)
protected String name;
@Column(nullable=false)
protected double version;
@Column(nullable=false)
protected char status;
@Column
protected String[] dependencies;
protected abstract void actions();
protected abstract void menuBuild();
protected abstract void init();
AutoCalPlugin.java:Code:
@Entity
@Table(name="pluginAutoCal")
public class AutoCalPlugin extends Plugin {
@Column(nullable=false)
String fileName = "AutoCal.jar";
public AutoCalPlugin() {
name = "AutoCal";
version = 1.0;
status = 'd';
}
@Override
public void init() {}
@Override
public void actions() {}
@Override
public void menuBuild() {}
If I start the program Hibernate said that the don't know the entity
(Unknown entity: de.floe.timernx.plugin.AutoCal.AutoCalPlugin) but in the listet class the Entity annotation is there.
What is wrong?
Here the
hibernate.cfg.xml:Code:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/timernx</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.connection.password">xxxx</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>