I have a project aiming to use standard JPA data access technology. We're evaluating certain persistence providers right now and have been trying ToplinkEssentials already. As it shows some flaws here and there Hibernate is the next candidate of choice.
I describe one named query in orm.xml:
Code:
<named-query name="User.findByUsername">
<query>SELECT u FROM User u WHERE u.username = ?1</query>
</named-query>
I do not use @NamedQuery anywhere, so it is the only named query in the entire project. Nevertheless I get
org.hibernate.DuplicateMappingException: Duplicate query mapping User.findByUsername
Here is the stacktrace:
Code:
21:25:26,656 INFO LocalContainerEntityManagerFactoryBean:218 - Building JPA container EntityManagerFactory for persistence unit 'minos'
21:25:26,686 INFO Version:15 - Hibernate Annotations 3.3.0.GA
21:25:26,700 INFO Environment:514 - Hibernate 3.2.5
21:25:26,704 INFO Environment:547 - hibernate.properties not found
21:25:26,705 INFO Environment:681 - Bytecode provider name : cglib
21:25:26,710 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
21:25:26,768 INFO Version:15 - Hibernate EntityManager 3.3.1.GA
21:25:26,790 DEBUG Ejb3Configuration:302 - Processing PersistenceUnitInfo [
name: minos
persistence provider classname: null
classloader: sun.misc.Launcher$AppClassLoader@33056f
Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@cf3710
excludeUnlistedClasses: false
JTA datasource: null
Non JTA datasource: org.apache.commons.dbcp.BasicDataSource@280492
Transaction type: RESOURCE_LOCAL
PU root URL: file:/Users/olivergierke/Documents/workspace/minos-core/target/classes/
Jar files URLs [
file:/Users/olivergierke/Documents/workspace/minos-core/target/classes/]
Managed classes names [
com.synyx.minos.core.domain.AbstractEntity
com.synyx.minos.core.domain.User
com.synyx.minos.core.domain.Role]
Mapping files names []
Properties []
21:25:26,790 DEBUG Ejb3Configuration:553 - Detect class: true; detect hbm: true
21:25:26,791 DEBUG Ejb3Configuration:553 - Detect class: true; detect hbm: true
21:25:26,853 INFO Ejb3Configuration:678 - found EJB3 @MappedSuperclass: com.synyx.minos.core.domain.AbstractEntity
21:25:26,855 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.Role
21:25:26,856 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.User
21:25:26,880 INFO Ejb3Configuration:678 - found EJB3 @MappedSuperclass: com.synyx.minos.core.domain.AbstractEntity
21:25:26,881 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.Role
21:25:26,882 INFO Ejb3Configuration:668 - found EJB3 Entity bean: com.synyx.minos.core.domain.User
21:25:26,933 DEBUG DTDEntityResolver:38 - trying to resolve system-id [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd]
21:25:26,933 DEBUG EJB3DTDEntityResolver:31 - recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
21:25:26,934 DEBUG EJB3DTDEntityResolver:40 - located [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd] in classpath
21:25:26,998 DEBUG DTDEntityResolver:38 - trying to resolve system-id [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd]
21:25:26,998 DEBUG EJB3DTDEntityResolver:31 - recognized EJB3 ORM namespace; attempting to resolve on classpath under org/hibernate/ejb
21:25:27,000 DEBUG EJB3DTDEntityResolver:40 - located [file:///Users/olivergierke/Documents/workspace/minos-core/orm_1_0.xsd] in classpath
21:25:27,079 DEBUG AnnotationConfiguration:244 - Execute first pass mapping processing
21:25:27,175 INFO QueryBinder:64 - Binding Named query: User.findByUsername => SELECT u FROM User u WHERE u.username = ?1
21:25:27,177 INFO DefaultListableBeanFactory:340 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d7ae: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,persistenceUnitManager,entityManagerFactory,org.springframework.orm.jpa.JpaTransactionManager#0]; root of factory hierarchy
Any ideas?
Thanks in advance...
Ollie