[Hibernate-JIRA] Created: (HHH-7160) Method NaturalIdXrefDelegate#cache() misses to remove obsolete entry in naturalIdToPkMap when NaturalId values changed
by Guenther Demetz (JIRA)
Method NaturalIdXrefDelegate#cache() misses to remove obsolete entry in naturalIdToPkMap when NaturalId values changed
----------------------------------------------------------------------------------------------------------------------
Key: HHH-7160
URL: https://hibernate.onjira.com/browse/HHH-7160
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.1
Environment: Hibernate4.1.1
Reporter: Guenther Demetz
Attachments: TestCaseNaturalIdChangeBetweenPersistAndFlush.jar
Method NaturalIdXrefDelegate#cache() misses to remove obsolete entry in naturalIdToPkMap when NaturalId values changed,
thus NaturalIdAccess delivers results even by searching with obsolete values (see attached Testcase).
Cause:
following instruction is missing in Method NaturalIdXrefDelegate#cache():
if ( initial != null ) {
if ( areSame( naturalIdValues, initial.getValues()) ) {
return false;
}
naturalIdToPkMap.remove(initial); // <-- this instruciton is missing
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HHH-7017) Envers does not work in case of resource-local transactions and manual session flush mode
by Vladimir Velikiy (JIRA)
Envers does not work in case of resource-local transactions and manual session flush mode
-----------------------------------------------------------------------------------------
Key: HHH-7017
URL: https://hibernate.onjira.com/browse/HHH-7017
Project: Hibernate ORM
Issue Type: Bug
Components: envers
Affects Versions: 3.6.9
Environment: Hibernate 3.6.9, MySQL 5.1.44-community, mysql-connector-java-5.1.6, Inno DB tables
Reporter: Vladimir Velikiy
When I set a manual hibernate session flush mode envers does not write data in database. With FlushMode.AUTO all works ok. I think the problem in in a method doBeforeTransactionCompletion of the AuditProcess.java:
if (FlushMode.isManualFlushMode(session.getFlushMode())) {
Session temporarySession = null;
try {
temporarySession = session.getFactory().openTemporarySession();
executeInSession(temporarySession);
temporarySession.flush();
} finally {
if (temporarySession != null) {
temporarySession.close();
}
}
} else {
executeInSession((Session) session);
// Explicity flushing the session, as the auto-flush may have already happened.
session.flush();
}
In non-jta environment temporary session connection transaction is not commited.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HHH-4962) @ManyToOne with @JoinTable fails
by Clint Popetz (JIRA)
@ManyToOne with @JoinTable fails
--------------------------------
Key: HHH-4962
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4962
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.2
Reporter: Clint Popetz
$ cat src/main/java/test/User.java
package test;
import javax.persistence.*;
import org.hibernate.envers.Audited;
import java.util.Set;
The below code fails with "org.hibernate.MappingException: Unable to read the mapped by attribute for widgets in test.User!" but is supported by JPA, at least under hibernate.
@Entity
@Audited
public class User
{
@Id
private long id;
@OneToMany(mappedBy="user")
private Set<Widget> widgets;
}
$ cat src/main/java/test/Widget.java
package test;
import javax.persistence.*;
import org.hibernate.envers.Audited;
@Entity
@Audited
public class Widget
{
@Id
private long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinTable(name = "widget_to_user",
joinColumns = @JoinColumn(name = "widget_id"),
inverseJoinColumns = @JoinColumn(name = "user_id"))
private User user;
}
--
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: (METAGEN-85) MixedConfigurationTest failing
by Guillaume Smet (JIRA)
MixedConfigurationTest failing
------------------------------
Key: METAGEN-85
URL: https://hibernate.onjira.com/browse/METAGEN-85
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.2.0.Final
Reporter: Guillaume Smet
Assignee: Hardy Ferentschik
Attachments: attach-attributes-to-the-right-entity.diff
This bug is related to this thread of the mailing list: http://lists.jboss.org/pipermail/hibernate-dev/2012-March/007894.html
>From my original post:
********
While working on Hibernate JPA Modelgen, I noticed that there are test
failures in MixedConfigurationTest . I thought it was because of my
own changes but I also have this problem with a fresh git clone from
the official repo:
Running org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 2.494
sec <<< FAILURE!
Results :
Failed tests:
testAccessTypeForXmlConfiguredEmbeddables(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Coordinates_ was not
generated.
testDefaultAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testExplicitXmlConfiguredAccessTypeApplied(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.Vehicle_ was not generated.
testMixedConfiguration(org.hibernate.jpamodelgen.test.mixedmode.MixedConfigurationTest):
org.hibernate.jpamodelgen.test.mixedmode.RentalCar_ was not generated.
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0
>From what I can see, there is at least a problem with
AnnotationMetaEntity.mergeInMembers: the merged in members aren't
really affected to the new entity as the hostingEntity of the
attribute is still the original entity.
In the case of the ZeroCoordinates entity, it leads to a compilation
error as the SingularAttribute import isn't added to the right context
(it's added to the original XmlMetaEmbeddable context instead of the
AnnotationEmbeddable context this attribute is attached to at the end
of the annotation processing). The content of the generated class is
as follows:
package org.hibernate.jpamodelgen.test.mixedmode;
import javax.annotation.Generated;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(ZeroCoordinates.class)
public abstract class ZeroCoordinates_ {
public static volatile SingularAttribute<ZeroCoordinates,
Float> longitude;
public static volatile SingularAttribute<ZeroCoordinates,
Float> latitude;
}
I was wondering if providing the way to overwrite the hostingEntity
(via removing the final and adding a setter) would be acceptable or
not?
********
Even if I do so (draft patch attached), I still have a test failing
claiming that ZeroCoordinates shouldn't have any attributes generated.
IMHO, there are 2 problems here:
- we need to decide if having the attributes generated for ZeroCoordinates is the wanted behaviour. Considering that they are explicitely declared in the XML mapping, I think so but, as there is an explicit test checking that they aren't, I'm not sure it's the expected behaviour;
- if we fix the above problem by removing the attributes from ZeroCoordinates, we need to write a test to show the problem of AnnotationMetaEntity.mergeInMembers and fix it (either with the patch provided or with another one doing the same thing).
Depending on what we decide, I can probably prepare a pull request for this problem if you want it.
--
Guillaume
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years
[Hibernate-JIRA] Created: (HHH-5291) Hibernate generates several join clauses for same table
by Igor Nikolaev (JIRA)
Hibernate generates several join clauses for same table
-------------------------------------------------------
Key: HHH-5291
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5291
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2
Reporter: Igor Nikolaev
Suppose you've got a mapping:
<class name="Class" table="TABLE1" dynamic-update="true">
<id name="id" type="int">
<column name="ID" />
<generator class="assigned" />
</id>
<discriminator column="CLASS_TYPE"/>
<property name="property1" type="string" column="PROPERTY1" update="false" insert="false"/>
<join table="TABLE2" optional="true">
<key column="ID" not-null="false"/>
<property name="property2" column="PROPERTY2"/>
</join>
<subclass name="Subclass" discriminator-value="SUBCLASS">
<join table="TABLE2">
<key column="swift_id"/>
<property name="property3" column="PROPERTY3"/>
</join>
</subclass>
</class>
As you can notice, we join the same table in subclass.
Expected result is that Hibernat generates a query like this one:
select
this_.ID,
this_.PROPERTY1,
this_1_.PROPERTY2,
this_1_.PROPERTY3
from
TABLE1 this_
left inner join
TABLE2 this_1_
on this_.ID=this_1_.ID
Instead, Hibernate joins TABLE2 twice and generates the following query:
select
this_.ID,
this_.PROPERTY1,
this_1_.PROPERTY2,
this_2_.PROPERTY3
from
TABLE1 this_
left inner join
TABLE2 this_1_
on this_.ID=this_1_.ID
left outer join
TABLE2 this_2_
on this_.ID=this_2_.ID
--
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