[Hibernate-JIRA] Created: (HHH-4712) Field named "id" (but not an @Id) in a class referenced via join table leads to "Column 'col_1_1_' not found" when retrieving old versions
by Simon MacMullen (JIRA)
Field named "id" (but not an @Id) in a class referenced via join table leads to "Column 'col_1_1_' not found" when retrieving old versions
------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-4712
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4712
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.0-Beta-2, 3.3.0.GA
Reporter: Simon MacMullen
Priority: Minor
Attachments: envers-bug.tar.gz
I have a child class referenced with a @OneToMany via a @JoinTable. This class has a field in it named "id", as well as a real @Id field called something else.
Envers seems to treat the field specially because it's called "id", which seems wrong. It seems to get confused and ends up trying to pull a column from a ResultSet which did not exist in the appropriate query.
I've attached a small test case. Run "mvn install" and the test case will throw an exception. Rename the field Child.id to anything else and "mvn install" will succeed.
The pom in the test case references 3.3.2.GA and Envers 1.2.0.GA-hibernate-3.3, but I've tried with 3.5.0.Beta-2 and got exactly the same result.
To save opening the tarball if you don't want to run it, the entity classes look like this:
@Entity
@Audited
public class Parent {
@GeneratedValue(generator="sequence_generator")
@GenericGenerator(name="sequence_generator", strategy="org.hibernate.id.enhanced.SequenceStyleGenerator")
@Id
public int id = 0;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "join_table",
joinColumns = @JoinColumn(name="parent_id"),
inverseJoinColumns = @JoinColumn(name="child_id"))
public List<Child> children;
}
@Entity
@Audited
public class Child {
@GeneratedValue(generator="sequence_generator")
@GenericGenerator(name="sequence_generator", strategy="org.hibernate.id.enhanced.SequenceStyleGenerator")
@Id
public int theRealId = 0;
// This is the problematic field - rename it to anything other than "id" and the test will pass.
public int id = 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
15 years
[Hibernate-JIRA] Commented: (HHH-1914) session.merge(persistentEntity) fails on unmodifiable collections
by Pedro Teixeira (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1914?page=c... ]
Pedro Teixeira commented on HHH-1914:
-------------------------------------
Actually, the problem I'm seeing (3.3.2.GA) is that, somehow, copyValues is not copying the a set when merging.
It is probably not related to unmodifiable set.
> session.merge(persistentEntity) fails on unmodifiable collections
> -----------------------------------------------------------------
>
> Key: HHH-1914
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1914
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Reporter: Emmanuel Bernard
> Priority: Minor
>
> Cat cat = new Cat();
> cat.setId( new CatPk() );
> cat.getId().setName( "titi" );
> cat.getId().setThoroughbred( "unknown" );
> Set<Woman> women = new HashSet<Woman>();
> Woman woman = new Woman();
> woman.setId( new WomanPk() );
> woman.getId().setFirstName( "Lady" );
> woman.getId().setLastName( "McBeth" );
> women.add( woman );
> cat.setHumanContacts( Collections.unmodifiableSet( women ) );
> Set<Cat> cats = new HashSet<Cat>();
> cats.add( cat );
> woman.setCats( Collections.unmodifiableSet(cats) );
> s.persist( cat );
> s.persist( woman );
> tx.commit();
> s.merge( woman );
> During merge, the entity is copied into itself (?)
> defaultmergeeventlistener.entityIsPersistent() => copyValues(persister, entity, entity, source, copyCache);
> java.lang.UnsupportedOperationException
> at java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037)
> at org.hibernate.collection.PersistentSet.clear(PersistentSet.java:247)
> at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:404)
> at org.hibernate.type.CollectionType.replace(CollectionType.java:449)
> at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437)
> at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282)
> at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:132)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:105)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
> at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
> at org.hibernate.test.annotations.manytomany.ManyToManyTest.testUnmodifiableCollection(ManyToManyTest.java:102)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at org.hibernate.test.annotations.TestCase.runTest(TestCase.java:67)
> at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> What is the reason for that? The spec says that
> "If X is a managed entity, it is ignored by the merge operation"
--
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
15 years
[Hibernate-JIRA] Commented: (HHH-1914) session.merge(persistentEntity) fails on unmodifiable collections
by Pedro Teixeira (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1914?page=c... ]
Pedro Teixeira commented on HHH-1914:
-------------------------------------
There still seems to be an issue using umodifiable collections.
I do not get exception, but the method DefaultMergeEventListener.mergeTransientEntity copy from copyCache does not produce a corrent object
(i.e. a collection is empty, while in the original it has an element). This seems to affect only validation right now.
> session.merge(persistentEntity) fails on unmodifiable collections
> -----------------------------------------------------------------
>
> Key: HHH-1914
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1914
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Reporter: Emmanuel Bernard
> Priority: Minor
>
> Cat cat = new Cat();
> cat.setId( new CatPk() );
> cat.getId().setName( "titi" );
> cat.getId().setThoroughbred( "unknown" );
> Set<Woman> women = new HashSet<Woman>();
> Woman woman = new Woman();
> woman.setId( new WomanPk() );
> woman.getId().setFirstName( "Lady" );
> woman.getId().setLastName( "McBeth" );
> women.add( woman );
> cat.setHumanContacts( Collections.unmodifiableSet( women ) );
> Set<Cat> cats = new HashSet<Cat>();
> cats.add( cat );
> woman.setCats( Collections.unmodifiableSet(cats) );
> s.persist( cat );
> s.persist( woman );
> tx.commit();
> s.merge( woman );
> During merge, the entity is copied into itself (?)
> defaultmergeeventlistener.entityIsPersistent() => copyValues(persister, entity, entity, source, copyCache);
> java.lang.UnsupportedOperationException
> at java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037)
> at org.hibernate.collection.PersistentSet.clear(PersistentSet.java:247)
> at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:404)
> at org.hibernate.type.CollectionType.replace(CollectionType.java:449)
> at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437)
> at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282)
> at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:132)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:105)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
> at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
> at org.hibernate.test.annotations.manytomany.ManyToManyTest.testUnmodifiableCollection(ManyToManyTest.java:102)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at org.hibernate.test.annotations.TestCase.runTest(TestCase.java:67)
> at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> What is the reason for that? The spec says that
> "If X is a managed entity, it is ignored by the merge operation"
--
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
15 years
[Hibernate-JIRA] Created: (HHH-4710) Hibernate Core Tutorial Documentation Fix
by Ben C (JIRA)
Hibernate Core Tutorial Documentation Fix
------------------------------------------
Key: HHH-4710
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4710
Project: Hibernate Core
Issue Type: Improvement
Components: documentation
Affects Versions: 3.3.2, 3.3.1
Environment: 3.3.2, 3.3.1
Reporter: Ben C
Priority: Minor
Hi,
I was following the Hibernate Tutorial in Part One of the Hibernate Core documentation (Hibernate_Core/hibernate_3.2/source_3.3.2.GA/documentation/manual/target/docbook/publish/en-US/html_single/index.html) and encountered a few exceptions for which fixes are suggested on Hibernate forums. These fixes include:
a) https://forum.hibernate.org/viewtopic.php?p=2400801
b) https://forums.hibernate.org/viewtopic.php?f=1&t=998189
Solution summary a)
1. Remove file:
hibernate-3.3.1.GA\lib\required\slf4j-api-1.5.2.jar
2. Add to your project two new files:
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
Solution summary b)
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version> <!-- Version added as fix -->
</dependency>
I am in the process of documenting a JBoss DevStudio (eclipse) Hibernate application for Red Hat (EAP 5.0) which consists of the Hibernate 3.3.2.GA component.
Having discovered the exceptions in the existing code, I am going to create a patch for the Community documentation including all of the code fixes (some paths in hibernate.cfg.xml files are wrong) and pom.xml alterations (<version>3.3.1.GA</version> tags) etc.
* Which version of Hibernate which you like me to focus on considering the Community (5.1 AS) and Red Hat (EAP 5.1) Hibernate versions differ?
* Also, as I have configured the tutorial in DevStudio (eclipse) and will be writing a Red Hat guide, would you like me to add the eclipse version to a Community document?
* I configured the tutorial for use with an Mysql database and will be writing the Red Hat version accordingly. Please advise whether you would like that content added to the community docs in place of the "in memory" hsqld database ?
Thanks,
Ben Clare
--
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
15 years