[
https://hibernate.onjira.com/browse/HHH-7139?page=com.atlassian.jira.plug...
]
Karsten Wutzke edited comment on HHH-7139 at 3/2/12 5:28 AM:
-------------------------------------------------------------
Yes, it's still present:
{code} [java] Hibernate version: 4.1.0.Final
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.annotations.common.Version
<clinit>
[java] INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.Version logVersion
[java] INFO: HHH000412: Hibernate Core {4.1.0.Final}
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: HHH000206: hibernate.properties not found
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.cfg.Environment buildBytecodeProvider
[java] INFO: HHH000021: Bytecode provider name : javassist
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.mapping.RootClass
checkCompositeIdentifier
[java] WARN: HHH000038: Composite-id class does not override equals():
main.PartnershipId
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.mapping.RootClass
checkCompositeIdentifier
[java] WARN: HHH000039: Composite-id class does not override hashCode():
main.PartnershipId
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000402: Using Hibernate built-in connection pool (not for production
use!)
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000115: Hibernate connection pool size: 20
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000006: Autocommit mode: true
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000401: using driver [org.hsqldb.jdbcDriver] at URL
[jdbc:hsqldb:mem:standalone;create=true]
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000046: Connection properties: {user=sa, autocommit=true,
release_mode=auto}
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.dialect.Dialect <init>
[java] INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
[java] Mrz 02, 2012 12:18:12 PM
org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
[java] INFO: HHH000268: Transaction strategy:
org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
[java] Mrz 02, 2012 12:18:12 PM
org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
[java] INFO: HHH000397: Using ASTQueryTranslatorFactory
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000228: Running hbm2ddl schema update
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000102: Fetching database metadata
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000396: Updating schema
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Companies
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: PQs
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Partnerships
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Companies
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: PQs
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Partnerships
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000232: Schema update complete
[java] Hibernate:
[java] select
[java] pq0_.id as id1_0_,
[java] pq0_.name as name1_0_
[java] from
[java] PQs pq0_
[java] where
[java] pq0_.id=?
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper
logExceptions
[java] WARN: SQL Error: -423, SQLState: S1000
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper
logExceptions
[java] ERROR: Invalid argument in JDBC call: parameter index out of range: 4
[java] Exception in thread "main" javax.persistence.RollbackException:
Error while committing the transaction
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:90)
[java] at main.Main.main(Main.java:43)
[java] Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: Invalid argument in JDBC call: parameter
index out
of range: 4
[java] at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1360)
[java] at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:78)
[java] ... 1 more
[java] Caused by: org.hibernate.exception.GenericJDBCException: Invalid argument in
JDBC call: parameter index out of range: 4
[java] at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
[java] at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
[java] at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
[java] at $Proxy12.setInt(Unknown Source)
[java] at
org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$1.doBind(IntegerTypeDescriptor.java:57)
[java] at
org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
[java] at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
[java] at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
[java] at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:358)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2610)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2853)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3297)
[java] at
org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
[java] at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
[java] at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
[java] at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
[java] at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
[java] at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
[java] at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
[java] at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:325)
[java] at
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
[java] at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
[java] ... 1 more
[java] Caused by: java.sql.SQLException: Invalid argument in JDBC call: parameter
index out of range: 4
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.outOfRangeArgument(Unknown Source)
[java] at org.hsqldb.jdbc.JDBCPreparedStatement.checkSetParameterIndex(Unknown
Source)
[java] at org.hsqldb.jdbc.JDBCPreparedStatement.setInt(Unknown Source)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
[java] ... 22 more
[java] Caused by: org.hsqldb.HsqlException: Invalid argument in JDBC call: parameter
index out of range: 4
[java] at org.hsqldb.error.Error.error(Unknown Source)
[java] ... 31 more
[java] Hibernate:
[java] select
[java] company0_.id as id0_0_,
[java] company0_.name as name0_0_
[java] from
[java] Companies company0_
[java] where
[java] company0_.id=?
[java] Hibernate:
[java] select
[java] partnershi0_.company_id as company1_2_0_,
[java] partnershi0_
[java] .pq_id as pq2_2_0_,
[java] partnershi0_.ordinal_nbr as ordinal3_2_0_
[java] from
[java] Partnerships partnershi0_
[java] where
[java] partnershi0_.company_id=?
[java] and partnershi0_.pq_id=?
[java] Persistent partnership = (1, 1, 0)
[java] Hibernate:
[java] insert
[java] into
[java] PQs
[java] (name, id)
[java] values
[java] (?, ?)
[java] Hibernate:
[java] insert
[java] into
[java] Companies
[java] (name, id)
[java] values
[java] (?, ?)
[java] Hibernate:
[java] insert
[java] into
[java] Partnerships
[java] (company_id, ordinal_nbr, pq_id)
[java] values
[java] (?, ?, ?)
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds{code}
Note line 43 is trans.commit(); (44 in the former test case)
was (Author: kwutzke):
Yes, it's still present:
{code} [java] Hibernate version: 4.1.0.Final
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.annotations.common.Version
<clinit>
[java] INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.Version logVersion
[java] INFO: HHH000412: Hibernate Core {4.1.0.Final}
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.cfg.Environment <clinit>
[java] INFO: HHH000206: hibernate.properties not found
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.cfg.Environment buildBytecodeProvider
[java] INFO: HHH000021: Bytecode provider name : javassist
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.mapping.RootClass
checkCompositeIdentifier
[java] WARN: HHH000038: Composite-id class does not override equals():
main.PartnershipId
[java] Mrz 02, 2012 12:18:11 PM org.hibernate.mapping.RootClass
checkCompositeIdentifier
[java] WARN: HHH000039: Composite-id class does not override hashCode():
main.PartnershipId
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000402: Using Hibernate built-in connection pool (not for production
use!)
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000115: Hibernate connection pool size: 20
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000006: Autocommit mode: true
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000401: using driver [org.hsqldb.jdbcDriver] at URL
[jdbc:hsqldb:mem:standalone;create=true]
[java] Mrz 02, 2012 12:18:11 PM
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
configure
[java] INFO: HHH000046: Connection properties: {user=sa, autocommit=true,
release_mode=auto}
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.dialect.Dialect <init>
[java] INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
[java] Mrz 02, 2012 12:18:12 PM
org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
[java] INFO: HHH000268: Transaction strategy:
org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
[java] Mrz 02, 2012 12:18:12 PM
org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
[java] INFO: HHH000397: Using ASTQueryTranslatorFactory
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000228: Running hbm2ddl schema update
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000102: Fetching database metadata
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000396: Updating schema
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Companies
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: PQs
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Partnerships
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Companies
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: PQs
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
[java] INFO: HHH000262: Table not found: Partnerships
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
[java] INFO: HHH000232: Schema update complete
[java] Hibernate:
[java] select
[java] pq0_.id as id1_0_,
[java] pq0_.name as name1_0_
[java] from
[java] PQs pq0_
[java] where
[java] pq0_.id=?
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper
logExceptions
[java] WARN: SQL Error: -423, SQLState: S1000
[java] Mrz 02, 2012 12:18:12 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper
logExceptions
[java] ERROR: Invalid argument in JDBC call: parameter index out of range: 4
[java] Exception in thread "main" javax.persistence.RollbackException:
Error while committing the transaction
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:90)
[java] at main.Main.main(Main.java:43)
[java] Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: Invalid argument in JDBC call: parameter
index out
of range: 4
[java] at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1360)
[java] at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:78)
[java] ... 1 more
[java] Caused by: org.hibernate.exception.GenericJDBCException: Invalid argument in
JDBC call: parameter index out of range: 4
[java] at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
[java] at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
[java] at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
[java] at $Proxy12.setInt(Unknown Source)
[java] at
org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$1.doBind(IntegerTypeDescriptor.java:57)
[java] at
org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
[java] at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
[java] at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
[java] at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:358)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2610)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2853)
[java] at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3297)
[java] at
org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
[java] at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
[java] at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
[java] at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
[java] at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
[java] at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
[java] at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
[java] at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:325)
[java] at
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
[java] at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
[java] at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
[java] ... 1 more
[java] Caused by: java.sql.SQLException: Invalid argument in JDBC call: parameter
index out of range: 4
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.Util.outOfRangeArgument(Unknown Source)
[java] at org.hsqldb.jdbc.JDBCPreparedStatement.checkSetParameterIndex(Unknown
Source)
[java] at org.hsqldb.jdbc.JDBCPreparedStatement.setInt(Unknown Source)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
[java] ... 22 more
[java] Caused by: org.hsqldb.HsqlException: Invalid argument in JDBC call: parameter
index out of range: 4
[java] at org.hsqldb.error.Error.error(Unknown Source)
[java] ... 31 more
[java] Hibernate:
[java] select
[java] company0_.id as id0_0_,
[java] company0_.name as name0_0_
[java] from
[java] Companies company0_
[java] where
[java] company0_.id=?
[java] Hibernate:
[java] select
[java] partnershi0_.company_id as company1_2_0_,
[java] partnershi0_
[java] .pq_id as pq2_2_0_,
[java] partnershi0_.ordinal_nbr as ordinal3_2_0_
[java] from
[java] Partnerships partnershi0_
[java] where
[java] partnershi0_.company_id=?
[java] and partnershi0_.pq_id=?
[java] Persistent partnership = (1, 1, 0)
[java] Hibernate:
[java] insert
[java] into
[java] PQs
[java] (name, id)
[java] values
[java] (?, ?)
[java] Hibernate:
[java] insert
[java] into
[java] Companies
[java] (name, id)
[java] values
[java] (?, ?)
[java] Hibernate:
[java] insert
[java] into
[java] Partnerships
[java] (company_id, ordinal_nbr, pq_id)
[java] values
[java] (?, ?, ?)
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds{code}
Note line 43 is trans.commit();
java.sql.SQLException: Invalid argument in JDBC call: parameter index
out of range when trying to persist an entity mapped with insertable = false, updatable =
false on @Column
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-7139
URL:
https://hibernate.onjira.com/browse/HHH-7139
Project: Hibernate ORM
Issue Type: Bug
Environment: Hibernate 4.0.0.CR4, HSQLDB 2.0, MySQL 5.1
Reporter: Karsten Wutzke
Attachments: hib-readonly-col.zip
The following mappings are all JPA 1.0 compatible (no derived identifiers):
{code:Company.java}
@Entity
@Table(name = "Companies")
public class Company
{
@Id
@Column
private Integer id;
@Column
private String name;
...
}
{code}
{code:PQ.java}
@Entity
@Table(name = "PQs")
public class PQ implements Serializable
{
@Id
@Column
private Integer id;
@Column
private String name;
...
}
{code}
{code:Partnership.java}
@Entity
@Table(name = "Partnerships")
@IdClass(value = PartnershipId.class)
public class Partnership implements Serializable
{
@Id
@Column(name = "pq_id", insertable = false, updatable = false)
private Integer pqId;
@Id
@Column(name = "company_id", insertable = false, updatable = false)
private Integer companyId;
@Column(name = "ordinal_nbr")
private Integer ordinalNbr;
@ManyToOne
@JoinColumn(name = "pq_id", referencedColumnName = "id")
private PQ pq;
@ManyToOne
@JoinColumn(name = "company_id", referencedColumnName = "id")
private Company company;
...
}
{code}
{code:PartnershipId.java}
public class PartnershipId implements Serializable
{
private Integer pqId;
private Integer companyId;
public PartnershipId()
{
}
public PartnershipId(Integer pqId, Integer companyId)
{
this.pqId = pqId;
this.companyId = companyId;
}
...
}
{code}
Note, the insertable = false, updatable = false on @JoinColumn relationships.
Running the following test code
{code:Main.java}
public class Main
{
private static String PERSISTENCE_UNIT_NAME = "standalonePu";
private static EntityManagerFactory emf;
private static EntityManager em;
private static EntityTransaction trans;
public static void main(String[] args)
{
setUp(PERSISTENCE_UNIT_NAME);
trans.begin();
PQ detachedPq = new PQ(1, "Test PQ");
Company detachedCompany = new Company(1, "Test Company");
PQ pq = em.merge(detachedPq);
Company company = em.merge(detachedCompany);
Partnership detachedPartnership = new Partnership(1, 1, 1);
detachedPartnership.setPQ(pq);
detachedPartnership.setCompany(company);
Partnership partnership = em.merge(detachedPartnership);
partnership = em.find(Partnership.class, new PartnershipId(1, 1));
System.out.println("Persistent partnership = ("
+ partnership.getPQId() + ", "
+ partnership.getCompanyId() + ", "
+ partnership.getOrdinalNbr() + ")");
trans.commit();
close();
}
private static void setUp(String puName)
{
emf = Persistence.createEntityManagerFactory(puName);
em = emf.createEntityManager();
trans = em.getTransaction();
}
private static void close()
{
em.close();
emf.close();
}
}
{code}
fails with a really strange exception:
ERROR: Invalid argument in JDBC call: parameter index out of range: 4
Exception in thread "main" javax.persistence.RollbackException: Error while
committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:90)
at main.Main.main(Main.java:44)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: Invalid argument in JDBC call: parameter
index out of range: 4
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1347)
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1280)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:78)
... 1 more
Caused by: org.hibernate.exception.GenericJDBCException: Invalid argument in JDBC
call: parameter index out of range: 4
at
org.hibernate.exception.internal.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:148)
at
org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:136)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:131)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:80)
at $Proxy12.setInt(Unknown Source)
at
org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$1.doBind(IntegerTypeDescriptor.java:57)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:82)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:358)
at
org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2599)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2836)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3276)
at
org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:80)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:186)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:344)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1084)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:319)
at
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:100)
at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:173)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
... 1 more
Caused by: java.sql.SQLException: Invalid argument in JDBC call: parameter index out
of range: 4
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.outOfRangeArgument(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.checkSetParameterIndex(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.setInt(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:124)
... 22 more
Caused by: org.hsqldb.HsqlException: Invalid argument in JDBC call: parameter index
out of range: 4
at org.hsqldb.error.Error.error(Unknown Source)
... 31 more
I've also tested this with MySQL with the same JDBC exception.
Note the workaround to resolve this is to put `..., insertable = false, updatable =
false` onto the relationships' `@JoinColumn`s (but it's not really what I want).
Please fix.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira