[Hibernate-JIRA] Created: (HHH-3716) Sybase - null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL
by Gail Badner (JIRA)
Sybase - null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL
----------------------------------------------------------------------------------------------
Key: HHH-3716
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3716
Project: Hibernate Core
Issue Type: Bug
Components: core
Environment: Sybase
Reporter: Gail Badner
Assignee: Gail Badner
Fix For: 3.2.x, 3.3.x, 3.4
Null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL. This happens because Hibernate persists a null Boolean value by calling:
PreparedStatement.setNull( index, java.sql.Types.BIT )
The SQL code, java.sql.Types.BIT, is used because the Hibernate BooleanType defines its code as java.sql.Type.BIT.
Sybase JDBC converts the null to 0, apparently because Sybase does not allow nullable bit columns.
This can be reproduced using an annotations unit test, Java5FeaturesTest.testAutoboxing()..
Sybase maps bit columns to tinyint, so when the unit test is executed, the column in the underlying table is actually of type tinyint, not bit. Sybase allows nullable tinyint columns, so there should be no problem persisting a null value as null.
I've verified that changing the call to:
PreparedStatement.setNull( index, java.sql.Types.TINYINT )
persists the null value without being converted to 0.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-5413) null values for columns mapped as "boolean" cause exception when saving entity with Sybase jdbc4
by Strong Liu (JIRA)
null values for columns mapped as "boolean" cause exception when saving entity with Sybase jdbc4
------------------------------------------------------------------------------------------------
Key: HHH-5413
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5413
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0.Beta1, 3.5.4, 3.5.3
Environment: Sybase jdbc4
Reporter: Strong Liu
ASE doesn't allow 'null' value for 'BIT' datatype;
While performing insert operation using jconn3.jar it permit you to have
'null' value, this 'null' value is converted into bit 0 by jconn3 & hence
ASE doesn't throw any exception;
But incase of jconn4.jar 'null' value is not converted into bit 0, hence
jconn4 directly reports an exception for 'null' value(which is the expected
correct behavior)
Hibernate persists a null Boolean value by calling:
PreparedStatement.setNull( index, java.sql.Types.BIT )
The SQL code, java.sql.Types.BIT, is used because the Hibernate BooleanType defines its code as java.sql.Type.BIT.
This can be reproduced using an annotations unit test, Java5FeaturesTest.testAutoboxing()..
Sybase maps bit columns to tinyint, so when the unit test is executed, the column in the underlying table is actually of type tinyint, not bit. Sybase allows nullable tinyint columns, so there should be no problem persisting a null value as null.
I've verified that changing the call to:
PreparedStatement.setNull( index, java.sql.Types.TINYINT )
persists the null value without being converted to 0.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-6454) Stafeful, no transaction and persist entity with generatedValue for ID : javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null
by pierre devreux (JIRA)
Stafeful, no transaction and persist entity with generatedValue for ID : javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6454
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6454
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.5, 3.6.3
Environment: OpenEJB 3.2.0,Java 6, Hibernate-entity-manager: 3.6.3, hibernate-validator:4.0.2.
Reporter: pierre devreux
Here my use case :
I have
* a _Service_ entity :
{code:title=Service.java|borderStyle=solid}
@Entity
@TableGenerator(name="ServiceGenerator", pkColumnName="pk_val", pkColumnValue= "service_id", valueColumnName="val",table= "IDENTIFIER")
public class Service {
@Id
@GeneratedValue(generator="ServiceGenerator", strategy=GenerationType.TABLE)
private long id;
private String name;
private String des;
public Service(){};
public Service(String name, String des) {
this.name = name;
this.des = des;
}
}
{code}
* a _ServiceSF / ServiceSFImpl_ stateful :
{code:title=ServiceSFImpl.java|borderStyle=solid}
@Stateful
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class ServiceSFImpl implements ServiceSF {
@PersistenceContext(name="unit", type=PersistenceContextType.EXTENDED)
EntityManager em;
public void persist(Service s) {
em.persist(s);
}
@Remove
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void remove() {
}
}
{code}
* a test
{code:title=Test.java|borderStyle=solid}
...
@Test
public void createServiceSF() throws NamingException {
ServiceSF sf = (ServiceSF) context.lookup("ServiceSFImplLocal");
Service s = new Service("name", desc");
sf.persist(s);
sf.remove();
}
...
{code}
When I launch it, persist method raise an exception : _javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null_ .
After looking the code, I saw that hibernate starts a new transaction to get the generated ID, and then resume the previous transaction. But in my case there is no transaction, and Hibernate throw an InvalidTransactionException.
Here the complete stack trace :
{code:title=Bar.java|borderStyle=solid}
javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is:
javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resume previously suspended transaction
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:359)
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:287)
at $Proxy44.persist(Unknown Source)
at net.atos.od.td.nda.ddd.rt.jee.impl.DomainTransactionImpl.persist(DomainTransactionImpl.java:163)
at net.atos.ddd.test.LauncherTest.createService_aroundBody0(LauncherTest.java:39)
at net.atos.ddd.test.LauncherTest.createService_aroundBody1$advice(LauncherTest.java:31)
at net.atos.ddd.test.LauncherTest.createService(LauncherTest.java:1)
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:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resume previously suspended transaction
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:678)
at org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:114)
at net.atos.od.td.nda.ddd.rt.jee.impl.GatewayImpl.persist(GatewayImpl.java:39)
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:597)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:162)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:144)
at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:164)
at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:92)
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:597)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:162)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:144)
at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:122)
at org.apache.openejb.core.stateful.StatefulContainer.businessMethod(StatefulContainer.java:566)
at org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:325)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:282)
... 32 more
Caused by: org.hibernate.HibernateException: Unable to resume previously suspended transaction
at org.hibernate.engine.transaction.Isolater$JtaDelegate.delegateWork(Isolater.java:147)
at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:67)
at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:74)
at org.hibernate.id.MultipleHiLoPerTableGenerator$1.getNextValue(MultipleHiLoPerTableGenerator.java:216)
at org.hibernate.id.enhanced.OptimizerFactory$LegacyHiLoAlgorithmOptimizer.generate(OptimizerFactory.java:351)
at org.hibernate.id.MultipleHiLoPerTableGenerator.generate(MultipleHiLoPerTableGenerator.java:213)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:69)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:179)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:135)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:808)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:782)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:786)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:672)
... 54 more
Caused by: javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null
at org.apache.geronimo.transaction.manager.TransactionManagerImpl.resume(TransactionManagerImpl.java:181)
at org.hibernate.engine.transaction.Isolater$JtaDelegate.delegateWork(Isolater.java:138)
... 68 more
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[Hibernate-JIRA] Created: (HHH-5998) Illegal parenthesis in generated Oracle SQL SELECT clause (when using subselect)
by Thomas Zangerl (JIRA)
Illegal parenthesis in generated Oracle SQL SELECT clause (when using subselect)
--------------------------------------------------------------------------------
Key: HHH-5998
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5998
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.6.0
Environment: Hibernate 3.6.0.Final (shipped as part of JBoss runtime environment 6), Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit
Reporter: Thomas Zangerl
Hi,
when using an HQL subselect with EXISTS where the selected object in the subselect is an entity with a composite primary key (mapping a join-table), Hibernate adds parenthesis to the query-list with the selected columns. Oracle does not accept SELECT statements with parenthesis around the query-list and fails.
Consider the following entities (non-relevant members omitted):
{code:java}
@Entity
@Table(name = "DEMANDE_MODULES")
public class ModulesRequest implements Serializable {
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -9083049226182530936L;
private Long id;
@Id
@Column(name = "DMD_ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="demandeSeq")
@SequenceGenerator(name="demandeSeq", sequenceName="S_EVA_DMD_ID", allocationSize = 1)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
{code}
{code:java}
@Entity
@Table(name = "EVALUATION")
public class Evaluation implements Serializable {
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -7258988774554733242L;
private Long id;
@Id
@Column(name = "EVA_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="evaluationSeq")
@SequenceGenerator(name="evaluationSeq", sequenceName="S_EVA_ID", allocationSize = 1)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
{code}
{code:java}
@Entity
@Table(name = "DEMANDE_EVALUATION")
@AssociationOverrides({
@AssociationOverride(name = "pk.request", joinColumns=@JoinColumn(name = "DMD_ID")),
@AssociationOverride(name = "pk.evaluation", joinColumns=@JoinColumn(name = "EVA_ID"))
})
public class EvaluationRequest implements Serializable {
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -7511793462359852575L;
private EvaluationRequestId pk;
public EvaluationRequest() {
this.pk = new EvaluationRequestId();
}
@EmbeddedId
public EvaluationRequestId getPk() {
return pk;
}
public void setPk(EvaluationRequestId pk) {
this.pk = pk;
}
}
{code}
{code:java}
@Embeddable
public class EvaluationRequestId implements Serializable {
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -2708732283791960577L;
private ModulesRequest request;
private Evaluation evaluation;
public void setRequest(ModulesRequest request) {
this.request = request;
}
@ManyToOne
@ForeignKey(name="FK_DMD_EVA_DMD_EVALUATIONS")
public ModulesRequest getRequest() {
return request;
}
public void setEvaluation(Evaluation evaluation) {
this.evaluation = evaluation;
}
@ManyToOne
@ForeignKey(name="FK_DMD_EVA_EVALUATION")
public Evaluation getEvaluation() {
return evaluation;
}
}
{code}
EvaluationRequest is a join table between Evaluation and ModulesRequest, hence the primary key is the composite of the primary keys of Evaluation and ModulesRequest.
If I now execute the following EJB-QL query
{code:java}
String testQuery = "SELECT request " +
"FROM ModulesRequest request " +
"WHERE EXISTS (" +
" SELECT evRequest " +
" FROM request.evaluationRequests evRequest) ";
Query testq = em.createQuery(testQuery);
testq.getResultList();
{code}
Hibernate generates the following SQL command from the above EJB-QL:
{code:sql}
select
modulesreq0_.DMD_ID as DMD1_145_,
modulesreq0_.COMMENTAIRE as COMMENTA2_145_,
modulesreq0_.SFP_ID as SFP3_145_,
modulesreq0_.SEM_ID as SEM4_145_
from
DEMANDE_MODULES modulesreq0_
where
exists (
select
(evaluation1_.EVA_ID,
evaluation1_.DMD_ID)
from
DEMANDE_EVALUATION evaluation1_
where
modulesreq0_.DMD_ID=evaluation1_.DMD_ID
)
{code}
This SQL fails in the second SELECT because Oracle does not accept parantheses in a select statement:
{code}
14:42:41,706 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-00907: missing right parenthesis
{code}
The parantheses do not get included if the EJBQL selects directly on EvalauationRequest (and not as a part of a subselect in EXISTS).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[Hibernate-JIRA] Created: (HHH-3843) @Audited and @ManyToMany relation problem - after modyfing an Entity: org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session ...
by Michał Maryniak (JIRA)
@Audited and @ManyToMany relation problem - after modyfing an Entity: org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session ...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3843
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3843
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: envers.jar 1.2.0, Hibernate 3.3.1, postgresql-8.3, jboss-4.2.3
Reporter: Michał Maryniak
Attachments: enverse.7z
There is a problem with unidirectional @ManyToMany relation.
This case is different than the one with inheritance: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3830.
The example is trival and code is as simple as it can be.
A single Person can have many roles, and one Role can by assigned to many Person entities.
@Entity
@Audited
public class Person implements Serializable {
(...)
@ManyToMany
public List<Role> getRoles() {
return roles;
}
(...)
}
and
@Entity
@Audited
public class Role implements Serializable {
(...)
}
And here comes a use case:
1) I create role 'admin'
2) I create role 'user'
3) I create person 'john' and add him a role 'admin'
4) I edit 'john' and add him second role 'user'
and I got an exception:
org.hibernate.NonUniqueObjectException with message: "a different object with the same identifier value was already associated with the session: [Person_Role_AUD#{roles_id=1, Person_id=5, REV=DefaultRevisionEntity(id = 7, revisionDate = 2009-04-01 10:46:32)}]"
If I add one role and remove the second one, or if I only remove a role - an Exception does not occur.
I attached a zip file with this simple SEAM project generated by seam-gen 2.1.1 GA.
I haven't included jar files, but project requires jar's "generated" with seam-gen (2.1.1) and following jar's have been replaced with new ones:
2008-06-13 13:09 313˙898 dom4j.jar 1.6.1
2009-03-23 13:01 285˙158 envers.jar 1.2.0-hibernate-3.3
2008-08-20 11:27 279˙714 hibernate-annotations.jar 3.4.0.GA
2008-08-20 11:31 66˙993 hibernate-commons-annotations.jar 3.1.0.GA
2008-08-20 12:19 119˙292 hibernate-entitymanager.jar 3.4.0.GA
2008-12-04 14:39 304˙236 hibernate-search.jar 3.1.0.GA
2008-09-10 14:01 62˙574 hibernate-validator.jar 3.1.0.GA
2008-09-10 13:27 2˙766˙130 hibernate.jar from hibernate-distribution-3.3.1.GA-dist
2008-06-13 13:09 13˙236 jta.jar 1.1 (from hibernate-distribution-3.3.1.GA-dist)
2008-12-04 14:41 818˙961 lucene-core.jar 2.4.0 701827 - 2008-10-05 16:44:37
2008-08-19 20:40 17˙384 slf4j-api.jar 1.5.2
If you wish - I can attach a file with my oryginal jar - but it would be a realy big file ;-)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months