-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Vererbung, Annotations -> Unknown entity
PostPosted: Fri Jul 06, 2007 11:28 am 
Newbie

Joined: Fri Jul 06, 2007 9:07 am
Posts: 5
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


Hallo,

ich habe ein Programm welches über Plugins erweiterbar ist. Diese Plugins liegen als JAR Dateien in einem Verzeichnis und werden durch den ServiceLoader Mechanismus von Java 6 geladen. Jedes Plugin ist in seinem eigenen Package gekapselt und enthält eine plugin spezifische Klasse (AutoCalPlugin) die von einer allgemeinen Klasse (Plugin) erbt.

Der PluginHandler soll das geladene abgeleitete Plugin Objekt nun in der DB speichern:

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();
       }
   }


Das Plugin Objekt ist eine abstrakte Klasse (Getter/Setter Methoden sind vorhanden nur hier im Post weggelassen)

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() {}   


Beim Ausführen des Programmes meckert Hibernate darüber, dass er die Entity nicht kennt (Unknown entity: de.floe.timernx.plugin.AutoCal.AutoCalPlugin) dabei ist sie doch in der genannten Klasse vorhanden.

Wo liegt der Fehler?

Hier noch die 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>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 07, 2007 11:48 am 
Newbie

Joined: Fri Jul 06, 2007 9:07 am
Posts: 5
Um mehr Leute zu erreichen habe ich den Post nochmal auf Englisch verfasst und auch gleich eine Antwort bekommen.

Siehe:
http://forum.hibernate.org/viewtopic.php?p=2358273#2358273


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.