Hello I will like to map a table that doesn t have a primary key
So there is no id column and no values
d'apres la faq java.developpez.com/faq/hibernate
s est possible avec
Code:
<id
column="nomColumn"
name="unNom"
type="LeType"
>
<generator class="assigned" />
</id>
Donc je l ai code et j’obtiens une erreur
Quote:
11:18:48,705 DEBUG QueryTranslator:207 - HQL: select from ca.canassistance.pojo.AvinfogePojo as base where base.noDossier = ?
11:18:48,705 DEBUG QueryTranslator:208 - SQL: select avinfogepo0_.ID as ID, avinfogepo0_.IG_ID_DOUBLE_ASS as IG_ID_DO2_, avinfogepo0_.IG_DT_EVENEMENT as IG_DT_EV3_, avinfogepo0_.IG_GROUPE_CLIENT as IG_GROUP4_, avinfogepo0_.IG_NO_DOSSIER as IG_NO_DO5_, avinfogepo0_.IG_NO_CERTIFICAT_SAM as IG_NO_CE6_, avinfogepo0_.IG_NO_CERTIFICAT as IG_NO_CE7_, avinfogepo0_.IG_NO_GROUPE as IG_NO_GR8_, avinfogepo0_.IG_ID_USER as IG_ID_USER, avinfogepo0_.IG_DT_MODIF as IG_DT_M10_, avinfogepo0_.IG_ID_ACCIDENT as IG_ID_A11_ from AVINFOGE avinfogepo0_ where (avinfogepo0_.IG_NO_DOSSIER=? )
11:18:48,705 DEBUG BatcherImpl:204 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:18:48,705 DEBUG SQL:230 - select avinfogepo0_.ID as ID, avinfogepo0_.IG_ID_DOUBLE_ASS as IG_ID_DO2_, avinfogepo0_.IG_DT_EVENEMENT as IG_DT_EV3_, avinfogepo0_.IG_GROUPE_CLIENT as IG_GROUP4_, avinfogepo0_.IG_NO_DOSSIER as IG_NO_DO5_, avinfogepo0_.IG_NO_CERTIFICAT_SAM as IG_NO_CE6_, avinfogepo0_.IG_NO_CERTIFICAT as IG_NO_CE7_, avinfogepo0_.IG_NO_GROUPE as IG_NO_GR8_, avinfogepo0_.IG_ID_USER as IG_ID_USER, avinfogepo0_.IG_DT_MODIF as IG_DT_M10_, avinfogepo0_.IG_ID_ACCIDENT as IG_ID_A11_ from AVINFOGE avinfogepo0_ where (avinfogepo0_.IG_NO_DOSSIER=? )
11:18:48,705 DEBUG BatcherImpl:253 - preparing statement
11:18:48,768 DEBUG StringType:46 - binding '5814' to parameter: 1
11:18:48,799 DEBUG JDBCExceptionReporter:49 - SQL Exception
java.sql.SQLException: ORA-00904: "AVINFOGEPO0_"."ID": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3361)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at ca.canassistance.model.dao.AvinfogeDAO.find(AvinfogeDAO.java:189)
at ca.canassistance.service.AvingogeServicePersistance.existAvinfogeCle(AvingogeServicePersistance.java:50)
at ca.canassistance.batch.MettreJourInfogene.creerInfogene(MettreJourInfogene.java:238)
at ca.canassistance.batch.MettreJourInfogene.traiterFichier(MettreJourInfogene.java:224)
at ca.canassistance.batch.MettreJourInfogene.traiter(MettreJourInfogene.java:184)
at ca.canassistance.batch.MettreJourInfogene.<init>(MettreJourInfogene.java:142)
at ca.canassistance.batch.MettreJourInfogene.main(MettreJourInfogene.java:839)
11:18:48,799 WARN JDBCExceptionReporter:57 - SQL Error: 904, SQLState: 42000
11:18:48,799 ERROR JDBCExceptionReporter:58 - ORA-00904: "AVINFOGEPO0_"."ID": invalid identifier
11:18:48,799 DEBUG BatcherImpl:211 - done closing: 0 open PreparedStatements, 0 open ResultSets
11:18:48,799 DEBUG BatcherImpl:275 - closing statement
11:18:48,814 DEBUG JDBCExceptionReporter:49 - Could not execute query
java.sql.SQLException: ORA-00904: "AVINFOGEPO0_"."ID": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3361)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at ca.canassistance.model.dao.AvinfogeDAO.find(AvinfogeDAO.java:189)
at ca.canassistance.service.AvingogeServicePersistance.existAvinfogeCle(AvingogeServicePersistance.java:50)
at ca.canassistance.batch.MettreJourInfogene.creerInfogene(MettreJourInfogene.java:238)
at ca.canassistance.batch.MettreJourInfogene.traiterFichier(MettreJourInfogene.java:224)
at ca.canassistance.batch.MettreJourInfogene.traiter(MettreJourInfogene.java:184)
at ca.canassistance.batch.MettreJourInfogene.<init>(MettreJourInfogene.java:142)
at ca.canassistance.batch.MettreJourInfogene.main(MettreJourInfogene.java:839)
11:18:48,814 WARN JDBCExceptionReporter:57 - SQL Error: 904, SQLState: 42000
11:18:48,814 ERROR JDBCExceptionReporter:58 - ORA-00904: "AVINFOGEPO0_"."ID": invalid identifier
11:18:49,968 DEBUG JDBCTransaction:82 - rollback
11:18:49,983 DEBUG SessionImpl:596 - transaction completion
11:18:50,591 DEBUG SessionImpl:578 - closing session
11:18:50,591 DEBUG SessionImpl:3383 - disconnecting session
11:18:50,591 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
11:18:50,591 DEBUG SessionImpl:596 - transaction completion
net.sf.hibernate.exception.SQLGrammarException: Could not execute query
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1557)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at ca.canassistance.model.dao.AvinfogeDAO.find(AvinfogeDAO.java:189)
at ca.canassistance.service.AvingogeServicePersistance.existAvinfogeCle(AvingogeServicePersistance.java:50)
at ca.canassistance.batch.MettreJourInfogene.creerInfogene(MettreJourInfogene.java:238)
at ca.canassistance.batch.MettreJourInfogene.traiterFichier(MettreJourInfogene.java:224)
at ca.canassistance.batch.MettreJourInfogene.traiter(MettreJourInfogene.java:184)
at ca.canassistance.batch.MettreJourInfogene.<init>(MettreJourInfogene.java:142)
at ca.canassistance.batch.MettreJourInfogene.main(MettreJourInfogene.java:839)
Caused by: java.sql.SQLException: ORA-00904: "AVINFOGEPO0_"."ID": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3361)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
... 8 more
Donc j’aimerai bien hibernate génère des valeurs de clé primaire pour les valeurs
Déjà dans la table et incrémente les nouvelles valeurs.