[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
13 years, 8 months
[Hibernate-JIRA] Created: (HHH-5529) Bulk delete on Entity with @ElementCollection ignores the @CollectionTable
by Pascal Thivent (JIRA)
Bulk delete on Entity with @ElementCollection ignores the @CollectionTable
--------------------------------------------------------------------------
Key: HHH-5529
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5529
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0.Beta4, 3.6.0.Beta3, 3.5.5, 3.6.0.Beta2, 3.6.0.Beta1, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0-Final, 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1
Environment: Hibernate 3.5.x, all database, all platforms.
Reporter: Pascal Thivent
Attachments: HHH-XXX.tar.gz
I have an entity with a collection of basic elements mapped with @ElementCollection:
{code}
@Entity
public class Foo {
@Id @GeneratedValue
private Long id;
@ElementCollection
@Column(name = "bar_column")
@CollectionTable(name = "Bar")
private Set<String> bars = new HashSet<String>();
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public Set<String> getBars() { return bars; }
public void setBars(Set<String> bars) { this.bars = bars; }
}
{code}
A bulk delete on this entity fails due to constraint violation on the collection table (Hibernate ignores the collection table).
I don't think that the following cascading restriction from the JPA 2.0 specification applies:
{quote}
h3. 4.10 Bulk Update and Delete Operations
...
A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities.
{quote}
In other words, Hibernate should handle the collection table as we have no way to bulk delete the basic elements from the collection table.
I have attached a test case allowing to reproduce the issue.
--
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
13 years, 8 months
[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
13 years, 8 months
[Hibernate-JIRA] Created: (HHH-5539) ParameterParser does not support escaped ' symbols
by Alexey Romanchuk (JIRA)
ParameterParser does not support escaped ' symbols
--------------------------------------------------
Key: HHH-5539
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5539
Project: Hibernate Core
Issue Type: Bug
Components: query-sql
Affects Versions: 3.6.0.Beta4
Environment: 3.6.0 and postgresql 8.2.1
Reporter: Alexey Romanchuk
I create native SQLQuery with createSQLQuery method.
Looks like ParameterParser incorrectly process queries with escaped ' symbol. For example query like "select * from a where a.b = 'asdf \' asdf'" works fine, but "select * from a where a.b = 'asdf \' asdf: '" fails with
org.hibernate.QueryException: Space is not allowed after parameter prefix ':' 'select * from a where a.b = 'asdf \' asdf''
at org.hibernate.engine.query.ParameterParser.parse(ParameterParser.java:92)
at org.hibernate.engine.query.ParamLocationRecognizer.parseLocations(ParamLocationRecognizer.java:75)
at org.hibernate.engine.query.QueryPlanCache.buildNativeSQLParameterMetadata(QueryPlanCache.java:149)
at org.hibernate.engine.query.QueryPlanCache.getSQLParameterMetadata(QueryPlanCache.java:79)
at org.hibernate.impl.AbstractSessionImpl.createSQLQuery(AbstractSessionImpl.java:146)
at org.hibernate.impl.SessionImpl.createSQLQuery(SessionImpl.java:1656)
--
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
13 years, 8 months
[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
13 years, 8 months
[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
13 years, 8 months
[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
13 years, 8 months