Hi I have a code who work on hibernate 2
But not in hibernate 3.
I what to delete all row on the table Xc4dvoy.
Code:
public void deleteAllRows() throws HibernateException {
Session session = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.delete("from Xc4dvoyPojo");
session.getTransaction().commit();
} catch (HibernateException e) {
session.getTransaction().rollback();
e.printStackTrace();
} finally {
HibernateUtil.getSessionFactory().close();
}
}
[code]
console
Quote:
2009-02-23 15:15:22 ca.canassistance.tools.Log info
INFO: Début du batch de la mettre à jour d une table temporaire réclamations Inclaims
16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
16 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
47 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
47 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
172 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Infogene.hbm.xml
234 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.InfogenePojo -> INFOGENE
250 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : DomainesDeValeurs.hbm.xml
265 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.DomainesDeValeursPojo -> DOMAINES_DE_VALEURS
265 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Xc4dvoy.hbm.xml
281 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.Xc4dvoyPojo -> XC4DVOY
281 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
359 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
359 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
359 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
375 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@s1ora01s:1521:s1ora01i
375 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=factcan, password=****}
562 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
562 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: Oracle JDBC driver, version: 10.2.0.2.0
562 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.Oracle10gDialect
578 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
578 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
578 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
578 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
578 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
578 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
578 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
578 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
578 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
578 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
578 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
578 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
578 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
625 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
828 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
org.hibernate.MappingException: Unknown entity: java.lang.String
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1365)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:100)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:793)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:771)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy0.delete(Unknown Source)
at ca.canassistance.model.dao.Xc4dvoyDAO.deleteAllRows(Xc4dvoyDAO.java:193)
at ca.canassistance.service.InClaimsServicePersistance.deleteAllRows(InClaimsServicePersistance.java:132)
at ca.canassistance.batch.ReclamerInClaims.viderTaBle(ReclamerInClaims.java:68)
at ca.canassistance.batch.ReclamerInClaims.<init>(ReclamerInClaims.java:60)
at ca.canassistance.batch.ReclamerInClaims.main(ReclamerInClaims.java:369)
and my hibernate cfg.xml
[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 >
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@s1ora01s:1521:s1ora01i</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.username">factcan</property>
<property name="hibernate.connection.password">factcan</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for Oracle (any version) -->
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<mapping resource="Infogene.hbm.xml"/>
<mapping resource="DomainesDeValeurs.hbm.xml"/>
<mapping resource="Xc4dvoy.hbm.xml"/>
</session-factory>
</hibernate-configuration>
[/code]
my hbm
[code]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="ca.canassistance.pojo">
<class
name="Xc4dvoyPojo"
table="XC4DVOY"
>
<meta attribute="sync-DAO">false</meta>
<id
name="id"
type="integer"
column="ID"
>
<generator class="increment"/>
</id>
<property
name="sttRegistnNum"
column="STT-REGISTN-NUM"
type="string"
not-null="false"
length="12"
/>
<property
name="sttRecordType"
column="STT_RECORD_TYPE"
type="string"
not-null="false"
length="1"
/>
<property
name="sttServiceLineNum"
column="STT_SERVICE_LINE_NUM"
type="integer"
not-null="false"
length="5"
/>
<property
name="sttAdjustmentAction"
column="STT_ADJUSTMENT_ACTION"
type="string"
not-null="false"
length="5"
/>
</class>
</hibernate-mapping>
[/code]
so I have a org.hibernate.MappingException: Unknown entity: java.lang.String wow.
Can someOne help please