Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0029947
TypeCategorySeverityReproducibilityDate SubmittedLast Update
design defect[Openbravo ERP] A. Platformmajoralways2015-05-20 17:562018-07-30 11:11
Reporterjorge-garciaView Statuspublic 
Assigned Toplatform 
PriorityurgentResolutionopenFixed in Version
StatusacknowledgedFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned To
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0029947: Wrong query launched when OBDal.getInstance.getSession.refresh(Object)

DescriptionWrong query launched when OBDal.getInstance.getSession.refresh(Object o) is executed
Steps To ReproduceWarehouse w = OBDal.getInstance().get(Warehouse.class, "B2D40D8A5D644DD89E329DC297309055");
System.out.println(w);
OBDal.getInstance().getSession().refresh(w);

* Refresh query must be the same as Get query.

Get Query:
select warehouse0_.M_Warehouse_ID as M1_653_1_, warehouse0_.AD_Client_ID as AD2_653_1_,
    warehouse0_.AD_Org_ID as AD3_653_1_, warehouse0_.IsActive as IsActive653_1_,
    warehouse0_.Created as Created653_1_, warehouse0_.CreatedBy as CreatedBy653_1_,
    warehouse0_.Updated as Updated653_1_, warehouse0_.UpdatedBy as UpdatedBy653_1_,
    warehouse0_.Value as Value653_1_, warehouse0_.Name as Name653_1_,
    warehouse0_.Description as Descrip11_653_1_, warehouse0_.C_Location_ID as C12_653_1_,
    warehouse0_.Separator as Separator653_1_, warehouse0_.IsShipper as IsShipper653_1_,
    warehouse0_.Shippercode as Shipper15_653_1_, warehouse0_.FromDocumentNo as FromDoc16_653_1_,
    warehouse0_.ToDocumentNo as ToDocum17_653_1_, warehouse0_.M_Returnlocator_ID as M18_653_1_,
    warehouse0_.M_Warehouse_Rule_ID as M19_653_1_, warehouse0_.Isallocated as Isalloc20_653_1_
from M_Warehouse warehouse0_
where warehouse0_.M_Warehouse_ID=?

Refresh Query:
select warehouse0_.M_Warehouse_ID as M1_653_1_, warehouse0_.AD_Client_ID as AD2_653_1_,
    warehouse0_.AD_Org_ID as AD3_653_1_, warehouse0_.IsActive as IsActive653_1_,
    warehouse0_.Created as Created653_1_, warehouse0_.CreatedBy as CreatedBy653_1_,
    warehouse0_.Updated as Updated653_1_, warehouse0_.UpdatedBy as UpdatedBy653_1_,
    warehouse0_.Value as Value653_1_, warehouse0_.Name as Name653_1_,
    warehouse0_.Description as Descrip11_653_1_, warehouse0_.C_Location_ID as C12_653_1_,
    warehouse0_.Separator as Separator653_1_, warehouse0_.IsShipper as IsShipper653_1_,
    warehouse0_.Shippercode as Shipper15_653_1_, warehouse0_.FromDocumentNo as FromDoc16_653_1_,
    warehouse0_.ToDocumentNo as ToDocum17_653_1_, warehouse0_.M_Returnlocator_ID as M18_653_1_,
    warehouse0_.M_Warehouse_Rule_ID as M19_653_1_, warehouse0_.Isallocated as Isalloc20_653_1_,
    locatorlis1_.M_Warehouse_ID as M10_653_3_, locatorlis1_.M_Locator_ID as M1_3_,
    locatorlis1_.M_Locator_ID as M1_359_0_, locatorlis1_.AD_Client_ID as AD2_359_0_,
    locatorlis1_.AD_Org_ID as AD3_359_0_, locatorlis1_.IsActive as IsActive359_0_,
    locatorlis1_.Created as Created359_0_, locatorlis1_.CreatedBy as CreatedBy359_0_,
    locatorlis1_.Updated as Updated359_0_, locatorlis1_.UpdatedBy as UpdatedBy359_0_,
    locatorlis1_.Value as Value359_0_, locatorlis1_.M_Warehouse_ID as M10_359_0_,
    locatorlis1_.PriorityNo as PriorityNo359_0_, locatorlis1_.IsDefault as IsDefault359_0_,
    locatorlis1_.X as X359_0_, locatorlis1_.Y as Y359_0_,
    locatorlis1_.Z as Z359_0_, locatorlis1_.Barcode as Barcode359_0_,
    locatorlis1_.EM_OBWHS_Type as EM17_359_0_
from M_Warehouse warehouse0_
 left outer join M_Locator locatorlis1_ on warehouse0_.M_Warehouse_ID=locatorlis1_.M_Warehouse_ID
where warehouse0_.M_Warehouse_ID=?
TagsPerformance
Attached Filesdiff file icon 29947-proposal.diff [^] (586 bytes) 2015-06-03 16:25 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to defect 00252783.0PR15Q3 closedjorge-garcia Openbravo ERP Long time to update a warehouse if it has thousends of locators 
depends on defect 0030083 newTriage Finance Openbravo ERP TestCosting fails adding one-to-many relationship to M_LandedCost 
related to defect 00303083.0PR15Q4 closedcaristu Openbravo ERP Use get instead of refresh when saving or updating a record 
related to feature request 0037064 closedcaristu Openbravo ERP upgrade hibernate 
related to defect 0040157 closedAtulOpenbravo Modules Cannot reactivate a remittance: deleted object would be re-saved by cascade (remove deleted object from associations) 
related to feature request 0040290 acknowledgedplatform Openbravo ERP do not generate one-to-many property in parent entity for all FK properties 
Not all the children of this issue are yet resolved or closed.

-  Notes
(0077869)
alostale (developer)
2015-05-28 14:17
edited on: 2019-02-28 12:02

Hibernate refreshes parent and 1st (only 1st) child (bag) that is marked as Link to Parent (isParent) because of cascade="all,delete-orphan" in generated mapping.

org.hibernate.persister.entity.AbstractEntityPersister.createLoaders()
  ...
  loaders.put(
        "refresh",
        new CascadeEntityLoader( this, CascadingAction.MERGE, getFactory() )

org.hibernate.loader.entity.CascadeEntityLoader
...
    JoinWalker walker = new CascadeEntityJoinWalker(
        persister,
        action,
        factory);


org.hibernate.loader.JoinWalker.walkEntityTree(OuterJoinLoadable, String, PropertyPath, int)
      if ( type.isAssociationType() ) {
        walkEntityAssociationTree(

org.hibernate.loader.JoinWalker.walkEntityAssociationTree(AssociationType, OuterJoinLoadable, int, String, PropertyPath, boolean, int)

int joinType = getJoinType(
        persister,
        subPath,
        propertyNumber,
        associationType,
        persister.getFetchMode( propertyNumber ),
        persister.getCascadeStyle( propertyNumber ),
        lhsTable,
        lhsColumns,
        nullable,
        currentDepth
    ); -> 1 (includes it)


org.hibernate.loader.JoinWalker.getJoinType(AssociationType, FetchMode, PropertyPath, String, String[], boolean, int, CascadeStyle)

cascadeStyle -> [STYLE_ALL,STYLE_DELETE_ORPHAN]
isJoinedFetchEnabled -> true

it only adds 1st collection
  protected boolean isTooManyCollections() {
    return countCollectionPersisters(associations)>0;
  }

(0078028)
alostale (developer)
2015-06-03 16:26

attached proposed fix
(0105993)
alostale (developer)
2018-07-27 15:55

It is still reproducible in Hibernate 5.3.2.

Asked in Hibernate forums [1].

[1] https://discourse.hibernate.org/t/onetomany-get-initialized-on-refresh/1127 [^]
(0105998)
alostale (developer)
2018-07-30 11:11

Reported in Hibernate issue tracker:

https://hibernate.atlassian.net/browse/HHH-12867 [^]

- Issue History
Date Modified Username Field Change
2015-05-20 17:56 jorge-garcia New Issue
2015-05-20 17:56 jorge-garcia Assigned To => platform
2015-05-20 17:56 jorge-garcia Modules => Core
2015-05-20 17:56 jorge-garcia Triggers an Emergency Pack => No
2015-05-20 17:56 jorge-garcia Relationship added related to 0025278
2015-05-21 11:02 alostale Priority high => urgent
2015-05-21 11:02 alostale Status new => acknowledged
2015-05-21 11:02 alostale Target Version => 3.0PR15Q3
2015-05-21 11:05 alostale Tag Attached: Performance
2015-05-21 11:09 jorge-garcia Steps to Reproduce Updated View Revisions
2015-05-28 14:17 alostale Note Added: 0077869
2015-06-03 16:25 alostale File Added: 29947-proposal.diff
2015-06-03 16:26 alostale Note Added: 0078028
2015-06-03 16:30 alostale Relationship added depends on 0030083
2015-06-15 09:59 alostale Target Version 3.0PR15Q3 =>
2015-07-03 10:23 caristu Relationship added related to 0030308
2015-11-06 11:05 alostale Type defect => design defect
2018-07-25 09:19 alostale Relationship added related to 0037064
2018-07-27 15:55 alostale Note Added: 0105993
2018-07-30 11:11 alostale Note Added: 0105998
2019-02-11 11:23 caristu Relationship added related to 0040157
2019-02-28 12:02 alostale Note Edited: 0077869 View Revisions
2019-02-28 12:51 alostale Relationship added related to 0040290


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker