-->
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.  [ 4 posts ] 
Author Message
 Post subject: Annotations werden ignoriert
PostPosted: Tue Jul 20, 2010 4:21 am 
Newbie

Joined: Tue Jul 20, 2010 3:56 am
Posts: 6
Hallo,

meine User Klasse arbeitet mit Annotations. Wenn ich diese User Klasse jedoch verwenden möchte, erhalte ich eine Fehlermeldung:
Code:
org.hibernate.MappingException: Unknown entity: dao.User
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:704)
   at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1475)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
...


Ich wäre sehr dankbar, wenn Hibernate meine Annotations respektieren würde. Wenn ich eine XML mit den Mappings anfertige funktioniert es ja schließlich auch. Vielen Dank!

Daniel


Top
 Profile  
 
 Post subject: Re: Annotations werden ignoriert
PostPosted: Wed Jul 21, 2010 6:33 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Hast du die Klasse denn in der hibernate.cfg.xml drin stehen?


Top
 Profile  
 
 Post subject: Re: Annotations werden ignoriert
PostPosted: Wed Jul 21, 2010 7:50 am 
Newbie

Joined: Tue Jul 20, 2010 3:56 am
Posts: 6
Ja.
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property>
      <property name="hibernate.connection.username">hibernate</property>
      <property name="hibernate.connection.password">password</property>
      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <property name="hibernate.show_sql">true</property>
      <property name="hibernate.format_sql">true</property>
      <property name="hibernate.hbm2ddl.auto">update</property>
      <mapping class="dao.User" />
   </session-factory>
</hibernate-configuration>

Schreibe ich den Klassennamen falsch, wird es entsprechend bemängelt. Der Log zeigt folgendes:
Code:
47 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.3-Final
342 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.3-Final
350 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
359 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
403 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
1234 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
1302 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
1303 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
2484 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
2494 [main] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
3066 [main] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
3105 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
3106 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
3106 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
3182 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernate
3184 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=hibernate, password=****}
5077 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.1.47
5077 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )
5304 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
5444 [main] INFO org.hibernate.engine.jdbc.JdbcSupportLoader - Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
5446 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
5449 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
5449 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
5450 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
5450 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
5450 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
5451 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
5451 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
5451 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
5486 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
5489 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
5490 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
5490 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
5490 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
5490 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
5499 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
5499 [main] INFO org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge - Cache provider: org.hibernate.cache.NoCacheProvider
5500 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
5500 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
5507 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
5509 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
5509 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
5509 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
5509 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
5509 [main] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
5814 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
5859 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
5872 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - Running hbm2ddl schema update
5875 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - fetching database metadata
5877 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - updating schema
5881 [main] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete


Top
 Profile  
 
 Post subject: Re: Annotations werden ignoriert
PostPosted: Thu Jul 22, 2010 7:29 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Der Kopf deiner Klasse und die Stelle an der du die verwendest wären hilfreich. ;-)

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.