Hello! I spent all the day trying fix this problem, but i can't :S
Can anybody help me? :)
Hibernate version: 3.0
Mapping documents:
Code:
<hibernate-mapping>
<class name="org.eprat.project.model.C_Recursoshumans" table="RecursosHumans" schema="public">
<id name="idRecurs" type="java.lang.Integer">
<column name="ID_Recurs" />
<generator class="sequence"></generator>
</id>
<many-to-one name="rols" class="org.eprat.project.model.C_Rols" fetch="select">
<column name="ID_Rol" />
</many-to-one>
<many-to-one name="projectes" class="org.eprat.project.model.C_Projectes" fetch="select">
<column name="ID_Projecte" />
</many-to-one>
<property name="RNom" type="java.lang.String">
<column name="R_Nom" length="40" />
</property>
<property name="RCognoms" type="java.lang.String">
<column name="R_Cognoms" length="40" />
</property>
<property name="RLogin" type="java.lang.String">
<column name="R_Login" length="40" />
</property>
<property name="RPassword" type="java.lang.String">
<column name="R_Password" length="40" />
</property>
<property name="RAssignat" type="java.lang.Integer">
<column name="R_Assignat" />
</property>
<set name="tasqueses" inverse="true">
<key>
<column name="ID_Recurs" />
</key>
<one-to-many class="org.eprat.project.model.C_Tasques" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
SessionFactory sessions = new Configuration().configure().buildSessionFactory();
Session session = sessions.openSession();
// Perform life-cycle operations under a transaction
Transaction tx = null;
try {
tx = session.beginTransaction();
C_Recursoshumans p1 = new C_Recursoshumans();
p1.setRLogin("usuari");
p1.setRPassword("password");
p1.setRNom("Albert");
p1.setRCognoms("test");
session.save(p1);
tx.commit();
tx = null;
} catch ( HibernateException e ) {
if ( tx != null ) tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
Full stack trace of any exception that occurs:Code:
03:29:55,328 INFO Environment:509 - Hibernate 3.2.3
03:29:55,328 INFO Environment:542 - hibernate.properties not found
03:29:55,328 INFO Environment:676 - Bytecode provider name : cglib
03:29:55,328 INFO Environment:593 - using JDK 1.4 java.sql.Timestamp handling
03:29:55,375 INFO Configuration:1426 - configuring from resource: /hibernate.cfg.xml
03:29:55,375 INFO Configuration:1403 - Configuration resource: /hibernate.cfg.xml
03:29:55,562 INFO Configuration:553 - Reading mappings from resource : org/eprat/project/model/C_Rols.hbm.xml
03:29:55,640 INFO HbmBinder:300 - Mapping class: org.eprat.project.model.C_Rols -> Rols
03:29:55,656 INFO Configuration:553 - Reading mappings from resource : org/eprat/project/model/C_Etapes.hbm.xml
03:29:55,687 INFO HbmBinder:300 - Mapping class: org.eprat.project.model.C_Etapes -> Etapes
03:29:55,734 INFO Configuration:553 - Reading mappings from resource : org/eprat/project/model/C_Tasques.hbm.xml
03:29:55,750 INFO HbmBinder:300 - Mapping class: org.eprat.project.model.C_Tasques -> Tasques
03:29:55,750 INFO Configuration:553 - Reading mappings from resource : org/eprat/project/model/C_Recursoshumans.hbm.xml
03:29:55,765 INFO HbmBinder:300 - Mapping class: org.eprat.project.model.C_Recursoshumans -> RecursosHumans
03:29:55,765 INFO Configuration:553 - Reading mappings from resource : org/eprat/project/model/C_Projectes.hbm.xml
03:29:55,781 INFO HbmBinder:300 - Mapping class: org.eprat.project.model.C_Projectes -> Projectes
03:29:55,781 INFO Configuration:1541 - Configured SessionFactory: null
03:29:55,781 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Rols.recursosHumanses -> RecursosHumans
03:29:55,796 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Etapes.tasqueses -> Tasques
03:29:55,796 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Tasques.tasqueses -> Tasques
03:29:55,796 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Recursoshumans.tasqueses -> Tasques
03:29:55,796 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Projectes.etapeses -> Etapes
03:29:55,796 INFO HbmBinder:2375 - Mapping collection: org.eprat.project.model.C_Projectes.recursosHumanses -> RecursosHumans
03:29:55,796 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
03:29:55,796 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
03:29:55,796 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
03:29:55,828 INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/BD_Projecte
03:29:55,828 INFO DriverManagerConnectionProvider:86 - connection properties: {user=albert, password=****}
03:29:55,921 INFO SettingsFactory:89 - RDBMS: PostgreSQL, version: 8.2.4
03:29:55,921 INFO SettingsFactory:90 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 505)
03:29:55,937 INFO Dialect:152 - Using dialect: org.hibernate.dialect.PostgreSQLDialect
03:29:55,953 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
03:29:55,953 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
03:29:55,953 INFO SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
03:29:55,953 INFO SettingsFactory:147 - Automatic session close at end of transaction: disabled
03:29:55,953 INFO SettingsFactory:154 - JDBC batch size: 15
03:29:55,953 INFO SettingsFactory:157 - JDBC batch updates for versioned data: disabled
03:29:55,953 INFO SettingsFactory:162 - Scrollable result sets: enabled
03:29:55,953 INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): disabled
03:29:55,953 INFO SettingsFactory:178 - Connection release mode: auto
03:29:55,953 INFO SettingsFactory:205 - Default batch fetch size: 1
03:29:55,953 INFO SettingsFactory:209 - Generate SQL with comments: disabled
03:29:55,953 INFO SettingsFactory:213 - Order SQL updates by primary key: disabled
03:29:55,953 INFO SettingsFactory:382 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
03:29:55,953 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
03:29:55,953 INFO SettingsFactory:221 - Query language substitutions: {}
03:29:55,953 INFO SettingsFactory:226 - JPA-QL strict compliance: disabled
03:29:55,953 INFO SettingsFactory:231 - Second-level cache: enabled
03:29:55,953 INFO SettingsFactory:235 - Query cache: disabled
03:29:55,953 INFO SettingsFactory:369 - Cache provider: org.hibernate.cache.NoCacheProvider
03:29:55,953 INFO SettingsFactory:250 - Optimize cache for minimal puts: disabled
03:29:55,953 INFO SettingsFactory:259 - Structured second-level cache entries: disabled
03:29:55,968 INFO SettingsFactory:286 - Statistics: disabled
03:29:55,968 INFO SettingsFactory:290 - Deleted entity synthetic identifier rollback: disabled
03:29:55,968 INFO SettingsFactory:305 - Default entity-mode: pojo
03:29:55,968 INFO SettingsFactory:309 - Named query checking : enabled
03:29:55,984 INFO SessionFactoryImpl:161 - building session factory
03:29:56,250 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
03:29:56,343 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: null
03:29:56,343 ERROR JDBCExceptionReporter:78 - Batch entry 0 insert into public.RecursosHumans (ID_Rol, ID_Projecte, R_Nom, R_Cognoms, R_Login, R_Password, R_Assignat, ID_Recurs) values (NULL, NULL, Albert, test, usuari, password, NULL, 7) was aborted. Call getNextException to see the cause.
03:29:56,343 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 42P01
03:29:56,343 ERROR JDBCExceptionReporter:78 - ERROR: relation "public.recursoshumans" does not exist
03:29:56,343 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.eprat.project.model.Test.main(Test.java:29)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into public.RecursosHumans (ID_Rol, ID_Projecte, R_Nom, R_Cognoms, R_Login, R_Password, R_Assignat, ID_Recurs) values (NULL, NULL, Albert, test, usuari, password, NULL, 7) was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2530)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.eprat.project.model.Test.main(Test.java:29)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into public.RecursosHumans (ID_Rol, ID_Projecte, R_Nom, R_Cognoms, R_Login, R_Password, R_Assignat, ID_Recurs) values (NULL, NULL, Albert, test, usuari, password, NULL, 7) was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2530)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1317)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2592)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 8 more
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1317)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2592)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 8 more
BUILD SUCCESSFUL (total time: 2 seconds)
Name and version of the database you are using: PostgreSQL 8.2The generated SQL (show_sql=true):Code:
CREATE TABLE "RecursosHumans"
(
"ID_Recurs" integer NOT NULL,
"ID_Rol" integer,
"ID_Projecte" integer,
"R_Nom" character varying(40),
"R_Cognoms" character varying(40),
"R_Login" character varying(40),
"R_Password" character varying(40),
"R_Assignat" integer,
CONSTRAINT "PK_RecursosHumans" PRIMARY KEY ("ID_Recurs"),
CONSTRAINT "Projectes_RecursosHumans" FOREIGN KEY ("ID_Projecte")
REFERENCES "Projectes" ("ID_Projecte") MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "Rols_RecursosHumans" FOREIGN KEY ("ID_Rol")
REFERENCES "Rols" ("ID_Rol") MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)