[Hibernate-JIRA] Created: (HHH-6941) Erroneous Javadoc for getReferencedProperty, getReferenceablePropertyIterator
by Hayo (JIRA)
Erroneous Javadoc for getReferencedProperty, getReferenceablePropertyIterator
-----------------------------------------------------------------------------
Key: HHH-6941
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6941
Project: Hibernate Core
Issue Type: Bug
Components: documentation
Affects Versions: 3.6.9, 4.0.0.Final
Reporter: Hayo
Priority: Minor
The Javadoc inside org.hibernate.mapping.PersistentClass is misleading and partly wrong. This is the case for all published versions of Hibernate.
- getReferencedProperty: Opposed to the documentation properties that are identifiers are *not* included.
- getReferenceablePropertyIterator: documentation refers to wrong documentation above and is not understandable
- getPropertyIterator: unclear wording [enhancement]
My proposal is to change the documentation as follows:
{code}.
/**
* Build an iterator over the properties defined on this class. The returned
* iterator only accounts for non-identifier properties (which excludes:
* {@code <id>}, {@code @Id}).
* <p/>
* Differs from {@link #getUnjoinedPropertyIterator} in that the iterator
* we return here will include properties defined as part of a join.
* <p/>
* Differs from {@link #getReferenceablePropertyIterator} in that the properties
* defined in superclasses of the mapping inheritance are not included.
*
* @return An iterator over non-identifier properties.
*/
public Iterator getPropertyIterator() {
/**
* Build an iterator of properties which may be referenced in association mappings.
* <p>
* Includes properties defined in superclasses of the mapping inheritance.
* Includes all properties defined as part of a join.
*
* @see #getReferencedProperty for a discussion of "referenceable"
* @return The property iterator.
*/
public Iterator getReferenceablePropertyIterator() {
/**
* Given a property path, locate the appropriate association mapping reference.
* Locates properties defined in superclasses of the mapping inheritance.
* Locates all properties defined as part of a join.
* <p/>
* A referenceable property is a property which can be a target of a foreign-key
* mapping ({@code <property-ref>}, {@code @*To*(mappedBy =}...).
* It cannot be an identifier.
*
* @param propertyPath The property path to resolve into a property reference.
* @return The referenced property (never null).
* @throws MappingException If the property could not be found.
*/
public Property getReferencedProperty(String propertyPath) throws MappingException {
{code}
Mind that this changes the contract on handling identifiers, alsthough this contract has never been fulfilled.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-5948) Trying to get a PluralAttributePath from a @MappedSuperclass throws org.hibernate.MappingException: Unknown collection role
by Oliver Ringel (JIRA)
Trying to get a PluralAttributePath from a @MappedSuperclass throws org.hibernate.MappingException: Unknown collection role
----------------------------------------------------------------------------------------------------------------------------
Key: HHH-5948
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5948
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.1, 3.6.0
Reporter: Oliver Ringel
Attachments: testcase-hibernate.tgz
I'm trying to get the PluralAttributePath from a collection defined in a MappedSuperclass
@Entity
public class Person extends PersonBase {
@Basic
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@MappedSuperclass
public abstract class PersonBase {
@Id
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@OneToMany()
private Set<Address> addresses = new HashSet<Address>();
public Set<Address> getAddresses() {
return addresses;
}
public void setAddresses(Set<Address> addresses) {
this.addresses = addresses;
}
}
Executing the following
criteriaQuery = criteriaBuilder.createQuery(Person.class);
root = criteriaQuery.from(Person.class);
Path<?> pathAddresses = root.get("addresses");
throws the exception
org.hibernate.MappingException: Unknown collection role: testcase.hibernate.PersonBase.addresses
at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701)
at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58)
at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:157)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:197)
at testcase.hibernate.HibernateTest.testMappedSuperclassPluralAttribute(HibernateTest.java:53)
--
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
[Hibernate-JIRA] Updated: (HHH-1870) org.hibernate.TransientObjectException: object references an unsaved transient
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870?page=c... ]
Gail Badner updated HHH-1870:
-----------------------------
Fix Version/s: (was: 4.0.1)
4.1.0
> org.hibernate.TransientObjectException: object references an unsaved transient
> -------------------------------------------------------------------------------
>
> Key: HHH-1870
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870
> Project: Hibernate Core
> Issue Type: Bug
> Environment: Hibernate 3.2.0 RC 2 from SVN tunk 2006/06/30
> Reporter: Sergey Vladimirov
> Assignee: Gail Badner
> Fix For: 4.1.0
>
> Attachments: manytoonelazy.zip, patch.txt
>
>
> JUnit test case shows strange error on commit():
> Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> BeanB beanB = new BeanB();
> beanB.setId(1);
> session.save(beanB);
> beanB = (BeanB) session.load(BeanB.class, 1);
> BeanA beanA = new BeanA();
> beanA.setId(2);
> beanA.setParent((BeanB) session.load(BeanB.class, 1));
> session.save(beanA);
> transaction.commit();
> session.close();
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ru.arptek.arpsite.data.manytoonelazy.BeanA.parent -> ru.arptek.arpsite.data.manytoonelazy.BeanB
> at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:273)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:257)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
> at ru.arptek.arpsite.data.manytoonelazy.TestWithoutCache.testFind(TestWithoutCache.java:57)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Temporary patch included. May be it is brokes other issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Commented: (HHH-1870) org.hibernate.TransientObjectException: object references an unsaved transient
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870?page=c... ]
Steve Ebersole commented on HHH-1870:
-------------------------------------
Gail, I think we decided to put your changes off until 4.1 because of API/SPI changes right? If so, can you adjust this fix version?
> org.hibernate.TransientObjectException: object references an unsaved transient
> -------------------------------------------------------------------------------
>
> Key: HHH-1870
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1870
> Project: Hibernate Core
> Issue Type: Bug
> Environment: Hibernate 3.2.0 RC 2 from SVN tunk 2006/06/30
> Reporter: Sergey Vladimirov
> Assignee: Gail Badner
> Fix For: 4.0.1
>
> Attachments: manytoonelazy.zip, patch.txt
>
>
> JUnit test case shows strange error on commit():
> Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> BeanB beanB = new BeanB();
> beanB.setId(1);
> session.save(beanB);
> beanB = (BeanB) session.load(BeanB.class, 1);
> BeanA beanA = new BeanA();
> beanA.setId(2);
> beanA.setParent((BeanB) session.load(BeanB.class, 1));
> session.save(beanA);
> transaction.commit();
> session.close();
> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ru.arptek.arpsite.data.manytoonelazy.BeanA.parent -> ru.arptek.arpsite.data.manytoonelazy.BeanB
> at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:273)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:257)
> at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
> at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
> at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:135)
> at ru.arptek.arpsite.data.manytoonelazy.TestWithoutCache.testFind(TestWithoutCache.java:57)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Temporary patch included. May be it is brokes other issue.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-6938) Clarify the use of getHibernateConfiguration and Configuration handling with JPA bootstrap
by Stephane Nicoll (JIRA)
Clarify the use of getHibernateConfiguration and Configuration handling with JPA bootstrap
------------------------------------------------------------------------------------------
Key: HHH-6938
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6938
Project: Hibernate Core
Issue Type: Task
Affects Versions: 3.6.5
Reporter: Stephane Nicoll
Hi,
I am willing to register custom types automatically when our application starts. We are using JPA2 and the EntityManager.
To do so I can use a method on the Configuration object (registerTypeOverride). When configuring the JPA container, the PersistenceProvider can be extended. That's what I am doing but I came to this code (Ejb3Configuration on 3.6.5)
{code:java}
/**
* This API is intended to give a read-only configuration.
* It is sueful when working with SchemaExport or any Configuration based
* tool.
* DO NOT update configuration through it.
*/
public AnnotationConfiguration getHibernateConfiguration() {
//TODO make it really read only (maybe through proxying)
return cfg;
}
{code}
I believe there is a TODO here that may lead to a change that would disallow me to use the configuration object to register new types on startup. If this TODO gets ever resolved (why?), what could I do to register new types?
Thanks
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-6917) Persist deleted entity in collection which is not removed from collection
by Wong D (JIRA)
Persist deleted entity in collection which is not removed from collection
-------------------------------------------------------------------------
Key: HHH-6917
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6917
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.9, 4.0.0.Final
Environment: PostgreSQL 9.0.4, MySQL 5.5, Spring 3.1, JPA 2.0
Reporter: Wong D
Attachments: delete-test-src.zip
In one-to-many relationship, hibernate will not delete the entity from the collection if the entity is deleted from the outside and was not removed from the collection. For example, we have two classes:
class A { @OneToMany(cascade=CascadeType.ALL) Collection<B> bs; }
class B { @ManyToOne A a;}
A has a collection of B, say b1, b2, b3.
The following code will raise EntityNotFoundException: deleted entity passed to persist B#null
for(B b : A.bs) {
BService.delete(b); // No call to persist(A)
}
After we delete the b1, the deletion of b2 will cause the error. A complete test case attached.
I found out before each query org.hibernate.event.def.AbstractFlushingEventListener class calls prepareEntityFlushes(EventSource session). If I delete one entity B but did not remove it from the collection A.bs, Hibernate will throw the exception "deleted entity passed to persist" when persisting A, even I did not call persist A. So the exception could be thrown any time (for example, it throws when I execute a SELECT query).
I am expecting a transparent action that Hibernate will update the collection directly. BTW, I test eclipselink and it did not complain about deleted entity.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years