[Hibernate-JIRA] Created: (HHH-5359) Derived entity usecase fails when the association is bidirectional
by Hardy Ferentschik (JIRA)
Derived entity usecase fails when the association is bidirectional
------------------------------------------------------------------
Key: HHH-5359
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5359
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.3
Reporter: Hardy Ferentschik
Fix For: 3.6
See https://forum.hibernate.org/viewtopic.php?f=9&t=1005649
The exception is
{noformat}
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.hibernate.test.annotations.derivedidentities.bidirectional.Dependent.emp in org.hibernate.test.annotations.derivedidentities.bidirectional.Employee.dependents
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:655)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:619)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1221)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:383)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.test.annotations.TestCase.buildConfiguration(TestCase.java:114)
at org.hibernate.test.annotations.HibernateTestCase.setUp(HibernateTestCase.java:133)
at org.hibernate.test.annotations.HibernateTestCase.runBare(HibernateTestCase.java:80)
at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
{noformat}
The mapping is as follows:
{code}
@Entity
public class Employee {
@Id
long empId;
String empName;
@OneToMany(mappedBy = "emp", fetch = FetchType.LAZY)
private Set<Dependent> dependents;
}
{code}
{code}
@Entity
//(a)IdClass(DependentId.class)
public class Dependent implements Serializable {
@Id
@ManyToOne
Employee emp;
String name;
}
{code}
It does not work with @IdClass either.
--
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
[Hibernate-JIRA] Created: (HHH-5280) "java.lang.IllegalArgumentException: object is not an instance of declaring class" when persisting a object graph containing the same transient objetc twice.
by Benjamin Lerman (JIRA)
"java.lang.IllegalArgumentException: object is not an instance of declaring class" when persisting a object graph containing the same transient objetc twice.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5280
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5280
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2
Db: All? (At least h2 and mysql)
Reporter: Benjamin Lerman
Priority: Critical
Attachments: hibernate-multi-parent.tgz, test.entity.TestCreate.txt
I attach a maven project showing the bug.
I have 3 classes, A, B, C with
C have a one-to-many unidirectional relation to B and A.
B have a one-to-many unidirectional relation to A.
Those relations are mapped by foreign keys.
The cascading properties for those relations are all save-update,persist
For each of those relations, the inverse cardinality is 1 (which means A must be associated with a B and a C, and B must be associated with a C).
I create an instance of C that I associate to an instance of B and an instance of A, and I associate the instance of B with the instance of A.
I then try to save C, and I get the attached exception.
For what I understood the problem is with the method StatefulPersistenceContext.getOwnerId: this method use a cache to retrieve the parent of the instance of A, but because A has 2 different parents (the instance of B and the instance of C), it does not retrieve the right one and try to call a method on the wrong entity.
--
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
[Hibernate-JIRA] Created: (HHH-3608) DB sequence numbers are not unique when using the pooled SequenceStyleGenerator in multiple JVMs with the same DB
by Matthias Gommeringer (JIRA)
DB sequence numbers are not unique when using the pooled SequenceStyleGenerator in multiple JVMs with the same DB
-----------------------------------------------------------------------------------------------------------------
Key: HHH-3608
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3608
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.3.0.SP1, 3.3.0.GA, 3.2.6
Environment: Hibernate 3.2.6, Oracle (any version)
Reporter: Matthias Gommeringer
Priority: Blocker
Attachments: PooledOptimizerTest.java
We have several Application Servers (=JVMs) running each of them using Hibernate-Objects with the SequenceStyleGenerator+pooled configured. In unpredictable time intervals it happens that hibernate assigns the same ID to two completely different objects which results in a UniqueConstraintViolation exception from the database. Here an example with a description where hibernate fails:
DB-Sequence setup:
start=0
increment=2
PooledOptimizer.generate() with 2 threads (first assignment of hiValue/value):
JVM-1 JVM-2
value=0=callback.nextval
value=2=callback.nextval
hiValue=4=callback.nextval
hiValue=6=callback.nextval
The problem's cause is in the PooledOptimizer.generate: when it initializes
the value+hiValue for the first time it invokes callback.nextValue() twice which
may provide values that do not belong to each other. The reason is that
between the assignment of "value" and "hiValue" another JVM can retrieve a
DB sequence value from the callback which leads to an inconsistent "value" and "hiValue"
relation (see example above).
A fix that works for multiple JVMs would be to invoke the "callback.getNextValue()" maximum once
per "optimizer.generate()" call:
public synchronized Serializable generate(AccessCallback callback) {
if ( hiValue < 0 ) {
value = callback.getNextValue();
hiValue = value + incrementSize;
}
else if ( value >= hiValue ) {
value = callback.getNextValue();
hiValue = value + incrementSize;
}
return make(value++);
}
I attached a testcase that prooves the described problem (you can see that the IDs "2" and "3" are assigned two times).
I would be very thankful if this problem could be fixed very soon since it is a showstopper which
occurs very unpredictably.
--
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
[Hibernate-JIRA] Created: (HHH-5325) Minor issues in test suite and suggestions for improvements
by Fred Toussi (JIRA)
Minor issues in test suite and suggestions for improvements
-----------------------------------------------------------
Key: HHH-5325
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5325
Project: Hibernate Core
Issue Type: Improvement
Components: testsuite
Affects Versions: 3.5.3
Environment: tested with HSQLDB 2.0
Reporter: Fred Toussi
Priority: Minor
hql:ASTParserLoadingTest : testComponentNullnessChecks()
String query = getDialect() instanceof DB2Dialect ?
"from Human where cast(? as string) is null" :
"from Human where ? is null"
The cast should be made by default. DB2 is highly SQL Standard conformant and displays the correct behaviour.
(SQL Standard Part 3: Call-Level Interface (SQL/CLI)) Others may "invent" a character type for the dynamic param.
-----------------------
legacy:FooBarTest : testFindByCriteria()
if(!(getDialect() instanceof TimesTenDialect)) {
list = s.createCriteria(Foo.class).setMaxResults(0).list();
assertTrue( list.size()==0 );
}
The test produces the equivalent to SQL statements with "FETCH 0 ROWS ONLY" or "LIMIT 0" etc. This is explicitly stated to cause a data exception according to SQL:2008. The row count must be at least 1.
-----------------------
org.hibernate.test.hql : Animal.hbm.xml
This snippet is used in several tests. Search for "centimeters".
<property name="heightInches">
<column name="height_centimeters" not-null="true"
read="height_centimeters / 2.54"
write="? * 2.54"/>
</property>
The target SQL column type is created as DOUBLE in most dialects. The dynamic variable in "? * 2.54" first resolves to DECIMAL because the "declared type" of the numeric literal is DECIMAL. It would be better to use "? * 2.54E0" as a hint to use DOUBLE.
--
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
[Hibernate-JIRA] Created: (HHH-5378) 3.5.3: @OrderColumn not updated when inserting
by Jürgen Zimmermann (JIRA)
3.5.3: @OrderColumn not updated when inserting
----------------------------------------------
Key: HHH-5378
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5378
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.3
Environment: JDK 1.6_20, Hibernate 3.5.3, Spring 3.0.3, Tomcat 7.0.0-beta
Reporter: Jürgen Zimmermann
I'm having an abstract entity class "AbstractKunde" und a derived class "Privatkunde" (see below). AbstractKunde references one-to-many the entity class "Bestellung" and also defines @OrderColumn.
However, when I create a new Bestellung object, then the column for @OrderColumn isn't updated.
@Entity
@Table(name = "kunde")
@Inheritance
@DiscriminatorColumn(name = "art", length = 1)
...
public abstract class AbstractKunde implements java.io.Serializable {
...
@OneToMany(mappedBy = "kunde")
@OrderColumn(name = "idx")
private List<Bestellung> bestellungen;
...
}
@Entity
@Table(name = "bestellung")
...
public class Bestellung implements java.io.Serializable {
...
@ManyToOne(optional = false)
@JoinColumn(name = "kunde_fk")
@NotNull(message = "{bestellverwaltung.bestellung.kunde.notNull}")
private AbstractKunde kunde;
...
}
@Entity
@DiscriminatorValue("P")
public class Privatkunde extends AbstractKunde {
...
}
--
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
[Hibernate-JIRA] Created: (HHH-5390) Index column on inverse List should throw a warning
by Chris Bredesen (JIRA)
Index column on inverse List should throw a warning
---------------------------------------------------
Key: HHH-5390
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5390
Project: Hibernate Core
Issue Type: Improvement
Components: annotations
Affects Versions: 3.5.3
Reporter: Chris Bredesen
The manual correctly warns against trying to map an indexed inverse collection on a List. However, a configuration containing this invalid mapping builds successfully but causes null values to be inserted for the index column.
Hibernate should be helpful and, if possible, throw a warning to the user (perhaps an error?) that explains the invalid combination. Here is an example that would run but produce invalid results:
@Entity
public class Parent {
@OneToMany(mappedBy="parent")
@OrderColumn(name="order")
private List<Child> children;
}
@Entity
public class Child {
@ManyToOne
private Parent parent;
}
The above is a typical one to many with the addition of @OrderColumn. Because Child owns the relationship, the index column is lost/ignored. Hibernate should warn about this.
--
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