[Hibernate-JIRA] Commented: (HHH-1395) Hierarchical entity data management using 'modified preorder tree traversal algorithm' (nested set trees)
by Josh Joy (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1395?page=c... ]
Josh Joy commented on HHH-1395:
-------------------------------
This is very useful. Are there plans to merge this to a hibernate module? Or is there another recommended Hibernate library for us to use?
> Hierarchical entity data management using 'modified preorder tree traversal algorithm' (nested set trees)
> ----------------------------------------------------------------------------------------------------------
>
> Key: HHH-1395
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1395
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core, query-hql
> Environment: Hibernate 3.1 plus Annotations extending EJB3 implementation
> Reporter: James Salt
> Attachments: nestedset.tar.gz, utils-parent-20091117.tar.gz
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> An enhancement to allow entities to exist in a managed tree (DAG) structure, via the use of property annotations and entity annotations. With an extension to the HQL language to mimic the Oracle recusive query clause.
> This would be classically be useful for Bill of Material uses, or any tree like entity structure.
> I have implemented a homebrew approach using the 'adjacency list method' , and a post persist call back method to set the node path. Although I think a more full blown optimised algorithm would be the 'modified preorder tree traversal algorithm'.
> In the annotations world this could be implemented using an annotation like @Hierarchical to the entity, with a @Parent (mask for @ManyToOne) annotation on the parent field/parameter and @Children (mask for @OneToMany) annotation on the list of children entities.
> Then a postupdate method could be implemented for the entity type, that recalculates the tree meta data -i.e. parent, left and right.
> I believe this would be a valuable extension (useful for many common data models) to the hibernate core product that could be exposed through annotations as I have discussed and the hbm.xml.
> The users of such a system would be aware of the performance implications on insert/update/delete, but gain a massive performance gain on querying a tree data model.
>
--
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-5833) Insertion failure of a second entity in 1-N relationship when using PROPERTY access instead of FIELD access
by Cyrille Charron (JIRA)
Insertion failure of a second entity in 1-N relationship when using PROPERTY access instead of FIELD access
-----------------------------------------------------------------------------------------------------------
Key: HHH-5833
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5833
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.1
Environment: Windows XP, JUnit test under Eclipse with HSQLDB.
Reporter: Cyrille Charron
Attachments: FamilyModel.zip, Hibernate-bug.txt, HibernateTest.zip
While testing JBossCache, i have stumbled onto an apparent bug of Hibernate,
which throws a LazyInitializationException
on a 1-N bi-directional relation between an entity Address
and two entities Person.
NB: there's no bug when using OpenJPA.
I have copied an extract of my java code
and the stack trace with a breakpoint on the exception
at line 366 into AbstractPersistentCollection.java
at the end of this issue report.
If i am right, the bug arises because Hibernate tries to initialize
a collection which is already in the state of initialization.
This bug appears when i link 2 Person entities to the same Address entity
via 1-N bi-directional relation, and if the Person's setter updates
the 2 sides of this relation-ship by calling itself the Address's setter
(this "helper" code in entities was to be sure
that the relation is updated on both sides, whoever is the owner).
In my example, this collection is the "inhabitants" attribute
of my entity Address, in which i try to add a second entity Person,
which has an attribute "address" pointing on the entity Address.
Here is the "helper" code of the Person's setter :
{code}
public boolean setAddress(Address address) {
boolean done = false;
if (this.address != address) {
if (this.address != null) this.address.remInhabitant(this);
this.address = address;
if (this.address != null) this.address.addInhabitant(this);
done = true;
}
return done;
}
{code}
My Stateless Session Bean had only to update one side of the relation :
{code}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void setAddressForPerson(int personId, int addressId) {
Address address = findAddress(addressId);
Person person = findPerson(personId);
...
person.setAddress(address);
}
{code}
In the stack trace we see that :
we call Person.setAddress(Address) on my SECOND entity Person
which calls PersistentSet.size() on Address's collection
which calls PersistentSet(AbstractPersistentCollection).initialize(boolean)
which calls TwoPhaseLoad.initializeEntity
which calls PojoEntityTuplizer.setPropertyValues
which calls Person.setAddress(Address) on my FIRST entity Person
which calls PersistentSet.size() on Address's collection
which calls PersistentSet(AbstractPersistentCollection).initialize(boolean)
which throws the LazyInitializationException
as if the relation between my FIRST entity Person and entity Address
has not finished its initialization.
This bug DISAPPEARS if i delete the "helper" code from my entity Person :
{code}
public boolean setAddress(Address address) {
this.address = address;
return true;
}
{code}
and if i update manually the both sides of the relation in my Session Bean :
{code}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void setAddressForPerson(int personId, int addressId) {
Address address = findAddress(addressId);
Person person = findPerson(personId);
...
if (person.getAddress() != null) person.getAddress().remInhabitant(person);
if (address != null) address.addInhabitant(person);
person.setAddress(address);
}
{code}
I join 3 files :
the model project (entities Person, Address and Family)
the test project (Bean and JUnit)
a resume of source code and the stack trace with some variables values.
--
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-3551) Boolean substitution in informix
by Rouvignac (JIRA)
Boolean substitution in informix
--------------------------------
Key: HHH-3551
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3551
Project: Hibernate Core
Issue Type: Bug
Components: query-sql
Affects Versions: 3.3.1
Environment: Hibernate 3.2
Informix 9.40
Reporter: Rouvignac
HQL Query :
select order from Order order where order.printed = ?
Parameter :
true, false, Boolean.TRUE or Boolean.FALSE
When the request is executed we get the following error :
SQLSTATE: IX000
SQL CODE: -674
674: Routine (equal) can not be resolved.
If as parameter we use "t" ot "f" everything works fine but it will not work with other DB.
As a workaround we can use :
property name="hibernate.query.substitutions">true t, false f</property>
I investigated in Dialects :
Dialect.java
public String toBooleanValueString(boolean bool) {
return bool ? "1" : "0";
}
PostgreSQLDialect.java
public String toBooleanValueString(boolean bool) {
return bool ? "true" : "false";
}
InformixDialect.java uses Dialect.java toBooleanValueString method.
In my mind toBooleanValueString should be added to InformixDialect.java as follow :
public String toBooleanValueString(boolean bool) {
return bool ? "t" : "f";
}
--
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-4511) Problems with polymorphic queries with SINGLE_TABLE inheritance strategy
by Karoly Gacsal (JIRA)
Problems with polymorphic queries with SINGLE_TABLE inheritance strategy
------------------------------------------------------------------------
Key: HHH-4511
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4511
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.0.Beta-1
Environment: envers 1.2.1
Hibernate 3.3.2
Reporter: Karoly Gacsal
Attachments: ChildAuditing.java
Inheritance strategy is SINGLE_TABLE (discriminator).
When I query for ParentType I do not get ChildType instances in the result, but ParentType instances.
I checked the problem against envers 1.2.1/Hibernate 3.3.2 and against Hibernate 3.5.0.Beta-1 too.
The testcase "\src\test\java\org\hibernate\envers\test\integration\inheritance\single\ChildAuditing.java"
passes, but when I change the two sides of the equals method in testPolymorphicQuery()'s second assert the testcase fails, because
the expected result is a ChildEntity, but in the result we get an instance of ParentEntity.
Attached you can find the testcases changed by me.
--
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-5831) DTDEntityResolver should recognize systemId http://hibernate.org/dtd/... in addition to http://www.hibernate.org/dtd/
by Michael Vorburger (JIRA)
DTDEntityResolver should recognize systemId http://hibernate.org/dtd/... in addition to http://www.hibernate.org/dtd/
---------------------------------------------------------------------------------------------------------------------
Key: HHH-5831
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5831
Project: Hibernate Core
Issue Type: Patch
Components: core
Affects Versions: 3.6.0
Reporter: Michael Vorburger
Priority: Minor
http://mifosforge.jira.com/browse/MIFOS-4456 identified a one of those "Hibernate tries to connect to http://hibernate.sourceforge.net at startup!" conditions.
On further analysis, and debug stepping-through the DTDEntityResolver, it turned out that some (but not all) *hbm.xml files (in Mifos) used e.g. http://hibernate.org/dtd/hibernate-configuration-3.0.dtd (note the missing www. before hibernate.org) instead of http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd - which is, actually, a valid URL as well, presumably because you DNS CNAME hiberate.org to www.hibernate.org (so this actually was never noticed before - it "worked", via Internet access).
Ideally, it would be nice & user friendly if the DTDEntityResolver would handle the (valid!) "shortened" system ID as well?
The suggested patch is to do something like:
{noformat}
private static final String HIBERNATE_NAMESPACE_SHORT = "http://hibernate.org/dtd/";
else if ( systemId.startsWith( HIBERNATE_NAMESPACE_SHORT ) ) {
log.debug( "recognized (short, no www.) hibernate namespace; attempting to resolve on classpath under org/hibernate/" );
source = resolveOnClassPath( publicId, systemId, HIBERNATE_NAMESPACE_SHORT );
}
{noformat}
--
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