Hello,
Hibernate version: 2.1 java 1.4
Name and version of the database you are using: Oracle 9i
I am trying to use a query which could populate a DTO object (one object per row); this object is not mapped as it does not correspond with any persistent entity (it is a report query).
The query is inspired on the example in Hibernate in action, chapter 7.4.1 new ItemRow(...
I get the error: No persister for: eu.cec.admin.ndp.util.dto.BatchOverviewLine
This error occurs before the sql is generated (show_sql is true).
I guess its looking for a persister, but BatchOverviewLine is intended as a transient object (class listed below).
Thanks for any feedback,
Jan
Mapping documents:
---------- hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@devora.cc.cec.eu.int:1522:appgrhd</property>
<property name="connection.username">u_ndp4wl_d</property>
<property name="connection.password">u_ndp4wl_d</property>
<!-- Miscellaneous Properties -->
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="use_outer_join ">true</property>
<property name="max_fetch_depth">2</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property>
<!-- mapping files-->
<mapping resource="config/scanbase/person.hbm.xml"/>
<mapping resource="config/commonMappings/systemUser.hbm.xml"/>
<mapping resource="config/commonMappings/role.hbm.xml"/>
<mapping resource="config/scanbase/batch.hbm.xml"/>
<mapping resource="config/scanbase/scanner.hbm.xml"/>
<mapping resource="config/scanbase/centreGest.hbm.xml"/>
<mapping resource="config/scanbase/scannedDocument.hbm.xml"/>
<mapping resource="config/scanbase/batchState.hbm.xml"/>
<mapping resource="config/scanbase/batchStateType.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-------- batch.hbm.xml with named query
<hibernate-mapping>
<class name="eu.cec.admin.ndp.object.domain.Batch" table="NDP_LOTS">
<id name="lotId">
<column name="LOT_ID" sql-type="NUMBER" not-null="true"/>
<generator class="sequence">
<param name="sequence">ndp_seq</param>
</generator>
</id>
<property name="valid" type="java.lang.Boolean" >
<column name="IS_VALID" sql-type="NUMBER" not-null="true"/>
</property>
<property name="utilCreat">
<column name="UTIL_CREAT" sql-type="VARCHAR2(200) " not-null="true"/>
</property>
<property name="utilModif">
<column name="UTIL_MODIF" sql-type="VARCHAR2(200) " not-null="true"/>
</property>
<set name="scannedDocuments" lazy="false"
outer-join="false" >
<key>
<column name="LOT_ID" not-null="true"/>
</key>
<one-to-many class="eu.cec.admin.ndp.object.domain.ScannedDocument"/>
</set>
<!-- many to many p.226 -->
<set name="batchStates"
cascade="all-delete-orphan"
inverse="true"
outer-join="false">
<key foreign-key="ELS_LOT_FK">
<column name="LOT_ID" />
</key>
<one-to-many class="eu.cec.admin.ndp.object.domain.BatchState"/>
</set>
<many-to-one name="scanner"
class="eu.cec.admin.ndp.object.domain.Scanner"
column="RSC_ID"
cascade="save-update"
not-null="true"/>
<many-to-one name="centreGest"
class="eu.cec.admin.ndp.object.domain.CentreGest"
column="RCG_ID"
cascade="save-update"
not-null="true"/>
</class>
<sql-query name="batchOverview" >
<![CDATA[
SELECT LOT.LOT_ID as {batch.lotId}, SCAN.RSC_ID as {batch.rscId}
UTL.USERID as {batch.userid}, STATETYPE.DESCRIPTION as {batch.stateDescription}
STATE.DATE_EFF_ETAT as {batch.stateDate}, COUNT(doc.DOC_ID) as {batch.cntDocuments}
FROM NDP_LOTS LOT,
NDP_ETATS_LOT_SCAN STATE,
NDP_REF_SCANNERS SCAN,
NDP_REF_ETATS STATETYPE,
NDP_DOCUMENTS_SCAN DOC,
NDP_UTILISATEURS UTL
WHERE STATE.LOT_ID = LOT.LOT_ID
AND LOT.RSC_ID = SCAN.RSC_ID
AND STATE.LOT_ID = LOT.LOT_ID
AND STATE.RET_ID = STATETYPE.RET_ID
AND STATE.UTL_ID = utl.UTL_ID
AND DOC.LOT_ID = LOT.LOT_ID
AND STATE.DATE_EFF_ETAT = (SELECT MAX(A.DATE_EFF_ETAT) FROM NDP_ETATS_LOT_SCAN A
WHERE A.LOT_ID = LOT.LOT_ID )
AND STATE.UTL_ID = :utlId
GROUP BY LOT.LOT_ID, SCAN.RSC_ID, UTL.USERID, STATETYPE.DESCRIPTION, STATE.DATE_EFF_ETAT
ORDER BY lot.LOT_ID DESC
]]>
<return alias="batch" class="eu.cec.admin.ndp.util.dto.BatchOverviewLine"/>
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public Collection getBatches2(Long rcgId, Long utlId,
Long batchId, Timestamp scannedDate) throws DatasourceException {
Collection result = null;
try {
Session session = Scanbase.getSession();
result = session.getNamedQuery("batchOverview")
.setLong("utlId", utlId.longValue())
.list();
return result;
} catch (HibernateException e) {
throw new DatasourceException(e.getMessage());
}
}
Full stack trace of any exception that occurs:
13:21:46,407 DEBUG object:39 - initializing hib. sessionfactory for scan database
13:21:46,537 INFO Environment:469 - Hibernate 2.1.6
13:21:46,547 INFO Environment:498 - hibernate.properties not found
13:21:46,547 INFO Environment:529 - using CGLIB reflection optimizer
13:21:46,567 INFO Configuration:895 - configuring from resource: /config/scanbase/hibernate.cfg.xml
13:21:46,597 INFO Configuration:867 - Configuration resource: /config/scanbase/hibernate.cfg.xml
13:21:46,877 INFO Configuration:331 - Mapping resource: config/scanbase/person.hbm.xml
13:21:47,278 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.Person -> NDP_PERSONNES
13:21:47,508 INFO Configuration:331 - Mapping resource: config/commonMappings/systemUser.hbm.xml
13:21:47,599 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.SystemUser -> NDP_UTILISATEURS
13:21:47,639 INFO Configuration:331 - Mapping resource: config/commonMappings/role.hbm.xml
13:21:47,689 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.Role -> NDP_SEC_ROLES
13:21:47,689 INFO Configuration:331 - Mapping resource: config/scanbase/batch.hbm.xml
13:21:47,799 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.Batch -> NDP_LOTS
13:21:47,869 INFO Configuration:331 - Mapping resource: config/scanbase/scanner.hbm.xml
13:21:47,899 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.Scanner -> NDP_REF_SCANNERS
13:21:47,909 INFO Configuration:331 - Mapping resource: config/scanbase/centreGest.hbm.xml
13:21:47,939 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.CentreGest -> NDP_REF_CENTRES_GEST
13:21:47,949 INFO Configuration:331 - Mapping resource: config/scanbase/scannedDocument.hbm.xml
13:21:48,009 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.ScannedDocument -> NDP_DOCUMENTS_SCAN
13:21:48,009 INFO Configuration:331 - Mapping resource: config/scanbase/batchState.hbm.xml
13:21:48,079 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.BatchState -> NDP_ETATS_LOT_SCAN
13:21:48,089 INFO Configuration:331 - Mapping resource: config/scanbase/batchStateType.hbm.xml
13:21:48,300 INFO Binder:229 - Mapping class: eu.cec.admin.ndp.object.domain.BatchStateType -> NDP_REF_ETATS
13:21:48,310 DEBUG CacheFactory:32 - cache for: eu.cec.admin.ndp.object.domain.BatchStateType usage strategy: read-only
13:21:48,310 WARN CacheFactory:36 - read-only cache configured for mutable: eu.cec.admin.ndp.object.domain.BatchStateType
13:21:48,350 INFO Configuration:1053 - Configured SessionFactory: null
13:21:48,350 INFO Configuration:627 - processing one-to-many association mappings
13:21:48,360 INFO Binder:1181 - Mapping collection: eu.cec.admin.ndp.object.domain.Batch.scannedDocuments -> NDP_DOCUMENTS_SCAN
13:21:48,380 INFO Binder:1181 - Mapping collection: eu.cec.admin.ndp.object.domain.Batch.batchStates -> NDP_ETATS_LOT_SCAN
13:21:48,400 INFO Binder:1181 - Mapping collection: eu.cec.admin.ndp.object.domain.BatchStateType.batchStates -> NDP_ETATS_LOT_SCAN
13:21:48,400 INFO Configuration:636 - processing one-to-one association property references
13:21:48,400 INFO Configuration:661 - processing foreign key constraints
13:21:48,480 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.OracleDialect
13:21:48,480 INFO SettingsFactory:59 - Maximim outer join fetch depth: 2
13:21:48,480 INFO SettingsFactory:63 - Use outer join fetching: true
13:21:48,490 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
13:21:48,500 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
13:21:48,740 INFO DriverManagerConnectionProvider:77 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@devora.cc.cec.eu.int:1522:appgrhd
13:21:48,750 INFO DriverManagerConnectionProvider:78 - connection properties: {user=u_ndp4wl_d, password=u_ndp4wl_d}
13:21:48,770 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
13:21:50,262 INFO SettingsFactory:103 - Use scrollable result sets: true
13:21:50,262 INFO SettingsFactory:106 - Use JDBC3 getGeneratedKeys(): false
13:21:50,262 INFO SettingsFactory:109 - Optimize cache for minimal puts: false
13:21:50,272 INFO SettingsFactory:115 - echoing all SQL to stdout
13:21:50,272 INFO SettingsFactory:118 - Query language substitutions: {}
13:21:50,272 INFO SettingsFactory:129 - cache provider: net.sf.ehcache.hibernate.Provider
13:21:50,283 INFO SettingsFactory:141 - query cache factory: net.sf.hibernate.cache.StandardQueryCacheFactory
13:21:50,293 INFO Configuration:1116 - instantiating and configuring caches
13:21:50,723 INFO SessionFactoryImpl:118 - building session factory
13:21:52,235 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
13:21:52,235 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
13:21:52,265 INFO StandardQueryCache:41 - starting query cache at region: net.sf.hibernate.cache.StandardQueryCache
13:21:52,265 WARN Plugin:95 - Could not find configuration for net.sf.hibernate.cache.StandardQueryCache. Configuring using the defaultCache settings.
13:21:52,265 DEBUG object:39 - scanbase: Starting new database transaction in this thread.
13:21:52,265 DEBUG object:39 - scanbase: Opening new Session for this thread.
eu.cec.admin.ndp.util.exceptions.DatasourceException: No persister for: eu.cec.admin.ndp.util.dto.BatchOverviewLine
at eu.cec.admin.ndp.object.dao.BatchDao.getBatches2(BatchDao.java:83)
at eu.cec.admin.ndp.test.PersistenceTest.batchTest(PersistenceTest.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at eu.cec.admin.ndp.test.BaseTest.runTest(BaseTest.java:15)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:57)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
13:21:52,516 DEBUG object:39 - Closing Session of this thread.
Process finished with exit code 0
BatchOverviewLine class
public class BatchOverviewLine implements Serializable {
private Long lotId;
private String userid;
private Long rscId;
private Timestamp stateDate;
private Long cntDocuments;
private Boolean valid;
private String stateDescription;
public BatchOverviewLine(Long cntDocuments, Long lotId, Long rscId, Timestamp stateDate, String stateDescription, String userid) {
this.cntDocuments = cntDocuments;
this.lotId = lotId;
this.rscId = rscId;
this.stateDate = stateDate;
this.stateDescription = stateDescription;
this.userid = userid;
}
public Long getCntDocuments() {
return cntDocuments;
}
public void setCntDocuments(Long cntDocuments) {
this.cntDocuments = cntDocuments;
}
public Timestamp getStateDate() {
return stateDate;
}
public void setStateDate(Timestamp stateDate) {
this.stateDate = stateDate;
}
public Long getLotId() {
return lotId;
}
public void setLotId(Long lotId) {
this.lotId = lotId;
}
public Long getRscId() {
return rscId;
}
public void setRscId(Long rscId) {
this.rscId = rscId;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public Boolean getValid() {
return valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
public String getStateDescription() {
return stateDescription;
}
public void setStateDescription(String stateDescription) {
this.stateDescription = stateDescription;
}
}
|