[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-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, 5 months
[Hibernate-JIRA] Created: (HV-443) Scope of ConstraintDescriptors sometimes wrong in type hierarchies
by Gunnar Morling (JIRA)
Scope of ConstraintDescriptors sometimes wrong in type hierarchies
------------------------------------------------------------------
Key: HV-443
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-443
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.1.0.Final
Reporter: Gunnar Morling
Fix For: 4.2.0.CR1
Using the BV meta data API it is possible to retrieve meta information on the constraints of given Java types. Using the {{ConstraintFinder}} API the scope of the constraints to retrieve meta data for can be restricted.
Due to the caching of meta data in {{BeanMetaDataCache}} it can happen under certain circumstances that constraints are declared in scope {{LOCAL_ELEMENT}}, although it should be {{HIERARCHY}} instead.
The following test demonstrates the bug:
{code:java}
public class CacheTest {
@Test
public void constraintsFromSuperTypeAreInLocalScopeWhenSuperTypeIsLoadedFromCache() {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
// loads BeanMetaData for A and puts it into the BeanMetaDataCache
PropertyDescriptor propertyDescriptorForSuperType = validator
.getConstraintsForClass(A.class).getConstraintsForProperty("foo");
Set<ConstraintDescriptor<?>> constraintDescriptorsFromSuperType = propertyDescriptorForSuperType
.findConstraints().lookingAt(Scope.LOCAL_ELEMENT)
.getConstraintDescriptors();
assertEquals(constraintDescriptorsFromSuperType.size(), 1);
// re-uses BeanMetaData for A from cache, keeps A's constraints in
// LOCAL_ELEMENT scope
PropertyDescriptor propertyDescriptorForSubType = validator
.getConstraintsForClass(B.class).getConstraintsForProperty("foo");
Set<ConstraintDescriptor<?>> constraintDescriptorsFromSubType = propertyDescriptorForSubType
.findConstraints().lookingAt(Scope.LOCAL_ELEMENT)
.getConstraintDescriptors();
// fails
assertEquals(constraintDescriptorsFromSubType.size(), 0, "No descriptor in LOCAL scope expected for B.foo");
}
@Test
public void constraintsFromSuperTypeAreInHierarchyScopeWhenSuperTypeIsNotLoadedFromCache() {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
// loads BeanMetaData for A when traversing B's hierarchy, A's constraints
// are correctly in HIERARCHY scope
PropertyDescriptor propertyDescriptorForSubType = validator
.getConstraintsForClass(B.class).getConstraintsForProperty("foo");
Set<ConstraintDescriptor<?>> constraintDescriptorsFromSubType = propertyDescriptorForSubType
.findConstraints().lookingAt(Scope.LOCAL_ELEMENT)
.getConstraintDescriptors();
assertEquals(constraintDescriptorsFromSubType.size(), 0, "No descriptor in LOCAL scope expected for B.foo");
constraintDescriptorsFromSubType = propertyDescriptorForSubType
.findConstraints().lookingAt(Scope.HIERARCHY)
.getConstraintDescriptors();
assertEquals(constraintDescriptorsFromSubType.size(), 1, "One descriptor in HIERARCHY scope expected for B.foo");
}
public static class A {
@NotNull
public String getFoo() {
return null;
}
}
public static class B extends A {
}
}
{code}
The bug is caused by retrieving the meta data for {{A}} from the cache when building the meta data for its sub-type {{B}} (see {{constraintsFromSuperTypeAreInLocalScopeWhenSuperTypeIsLoadedFromCache}}). In this case the constraint from {{A}} are added to {{B}} but remain in scope {{LOCAL_ELEMENT}}.
The bug does not occur when the meta data for {{A}} is retrieved when traversing the type hierarchy while building up the meta data for {{B}} (see {{constraintsFromSuperTypeAreInHierarchyScopeWhenSuperTypeIsNotLoadedFromCache}}), though I guess the constraints would be wrongly in scope {{HIERARCHY}} if afterwards the descriptors for {{A}} itself would be retrieved.
To fix this bug the constraint scope needs to be re-determined always if the meta data is retrieved from the cache.
--
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