Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Fetch Eager and container
Fetch Eager and container [message #425853] Wed, 10 December 2008 09:15 Go to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
Hi All,

I have a problem with EMF/Teneo and container/containment on relation with
e Fetch Eager

Here is my relation:
Resource --(scheduledActivities 0..n)->ActivitiyInstance
--(processInstance 0..1)-> ProcessInstance

scheduledActivities:
*container,containment to false
*EOpposite fill
*teneo: @ManyToMany(indexed=true, fetch=LAZY,
cascade=NONE,mappedBy=AssignedResources)

processInstance:
*container true, containment false
*EOpposite fill
*teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)

When I request a resource with its scheduled activities and
processInstances, the result is a Resource, with its scheduled activities,
but without it processInstance (on debug, I see that their are no
eContainer, and the getProcessInstance give the eContainer).
The Sql request is good when I explicitly ask processInstance, but not
good if I didn't explicitly ask it.
It is as Fetch EAGER doesn't work on container...
Have you ever seen something like that ?
Am I wrong ?
Thanks to help me
Regards

Thomas
Re: Fetch Eager and container [message #425857 is a reply to message #425853] Wed, 10 December 2008 09:33 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
I am not sure that I fully understand what you mean:
- do you expect the ProcessInstance to be loaded in the top of the resource?, or
- is the processInstance many-to-one not eagerly fetched?

Can you post the snippet of the hbm which relates to this?

gr. Martin

Thomas wrote:
> Hi All,
>
> I have a problem with EMF/Teneo and container/containment on relation
> with e Fetch Eager
>
> Here is my relation:
> Resource --(scheduledActivities 0..n)->ActivitiyInstance
> --(processInstance 0..1)-> ProcessInstance
>
> scheduledActivities:
> *container,containment to false
> *EOpposite fill
> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
> cascade=NONE,mappedBy=AssignedResources)
>
> processInstance:
> *container true, containment false
> *EOpposite fill
> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>
> When I request a resource with its scheduled activities and
> processInstances, the result is a Resource, with its scheduled
> activities, but without it processInstance (on debug, I see that their
> are no eContainer, and the getProcessInstance give the eContainer).
> The Sql request is good when I explicitly ask processInstance, but not
> good if I didn't explicitly ask it.
> It is as Fetch EAGER doesn't work on container...
> Have you ever seen something like that ?
> Am I wrong ?
> Thanks to help me
> Regards
>
> Thomas
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Fetch Eager and container [message #425859 is a reply to message #425857] Wed, 10 December 2008 09:54 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
Hi Martin,

No, the ProcessInstance has to be into the ActivityInstance.
Yes, it is the many-to-one that is not fetch eager or fetch within the
jpql request.
My request is to get a resource, with its ActivityInstance which should
contain a ProcessInstance
I hope I am clear now ;)

How can I have the hbm ? The model is generated
I can give you a part of the ModelPackageImpl
public void initializePackageContents() {
....
// Initialize classes and features; add operations and parameters
initEClass(resourceEClass, Resource.class, "Resource", !IS_ABSTRACT,
!IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
....
initEReference(getResource_ScheduledActivities(),
this.getActivityInstance(),
this.getActivityInstance_AssignedResources(), "scheduledActivities",
null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
!IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE,
!IS_DERIVED, IS_ORDERED);
....
initEClass(activityInstanceEClass, ActivityInstance.class,
"ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
IS_GENERATED_INSTANCE_CLASS);
....
initEReference(getActivityInstance_AssignedResources(),
this.getResource(), this.getResource_ScheduledActivities(),
"assignedResources", null, 0, -1, ActivityInstance.class, !IS_TRANSIENT,
!IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
....
initEReference(getActivityInstance_ProcessInstance(),
this.getProcessInstance(), this.getProcessInstance_Activities(),
"processInstance", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT,
!IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES,
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
....
initEClass(processInstanceEClass, ProcessInstance.class,
"ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
IS_GENERATED_INSTANCE_CLASS);
....
initEReference(getProcessInstance_Activities(),
this.getActivityInstance(), this.getActivityInstance_ProcessInstance(),
"activities", null, 0, -1, ProcessInstance.class, !IS_TRANSIENT,
!IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
....
}


My request is:
SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH r.scheduledActivities
a LEFT JOIN FETCH a.ProcessInstance where r.id=:id

If I ask to hibernate to print the Sql request, it is pretty good, with
processInstance data but it is as the mapping doesn't work ???

Before, I have done this request:
SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH r.scheduledActivities
a where r.id=:id
As the Fetch is Eager into the description, and then, the sql request
print by hibernate doesn't contain any ProcessInstance data ...

It is as the container/containment relationship is not understood into
teneo ...

This is what I try to tell you the first time. Am I more clear now ?

Thank you to have answer so quickly
Regards

Thomas

Martin Taal a écrit :
> Hi Thomas,
> I am not sure that I fully understand what you mean:
> - do you expect the ProcessInstance to be loaded in the top of the
> resource?, or
> - is the processInstance many-to-one not eagerly fetched?
>
> Can you post the snippet of the hbm which relates to this?
>
> gr. Martin
>
> Thomas wrote:
>> Hi All,
>>
>> I have a problem with EMF/Teneo and container/containment on relation
>> with e Fetch Eager
>>
>> Here is my relation:
>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>> --(processInstance 0..1)-> ProcessInstance
>>
>> scheduledActivities:
>> *container,containment to false
>> *EOpposite fill
>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>> cascade=NONE,mappedBy=AssignedResources)
>>
>> processInstance:
>> *container true, containment false
>> *EOpposite fill
>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>
>> When I request a resource with its scheduled activities and
>> processInstances, the result is a Resource, with its scheduled
>> activities, but without it processInstance (on debug, I see that their
>> are no eContainer, and the getProcessInstance give the eContainer).
>> The Sql request is good when I explicitly ask processInstance, but not
>> good if I didn't explicitly ask it.
>> It is as Fetch EAGER doesn't work on container...
>> Have you ever seen something like that ?
>> Am I wrong ?
>> Thanks to help me
>> Regards
>>
>> Thomas
>>
>
>
Re: Fetch Eager and container [message #425861 is a reply to message #425859] Wed, 10 December 2008 10:07 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
By the way, I have forgotten to tell you that we are using the
EntityManager and to give you some other parts of the ModelPackageImpl:

protected void createTeneoAnnotations() {
String source = "teneo.hibernate";
addAnnotation
(resourceEClass,
source,
new String[]
{
"appinfo", "@Table(name=\"Oresource\")"
});
....
addAnnotation
(getActivityInstance_ProcessInstance(),
source,
new String[]
{
"appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
});
....
addAnnotation
(getProcessInstance_Activities(),
source,
new String[]
{
"appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
mappedBy=processInstance)"
});
....
addAnnotation
(getProcess_Activities(),
source,
new String[]
{
"appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
});
....
}
protected void createTeneo_1Annotations()
String source = "teneo.jpa";
addAnnotation
(getResource_ScheduledActivities(),
source,
new String[]
{
"appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
cascade=NONE,mappedBy=assignedResources)"
});
....
addAnnotation
(getActivityInstance_AssignedResources(),
source,
new String[]
{
"appinfo", "@ManyToMany(indexed=true, fetch=LAZY, cascade=NONE)"
});
....
}




Thomas a écrit :
> Hi Martin,
>
> No, the ProcessInstance has to be into the ActivityInstance.
> Yes, it is the many-to-one that is not fetch eager or fetch within the
> jpql request.
> My request is to get a resource, with its ActivityInstance which should
> contain a ProcessInstance
> I hope I am clear now ;)
>
> How can I have the hbm ? The model is generated
> I can give you a part of the ModelPackageImpl
> public void initializePackageContents() {
> ...
> // Initialize classes and features; add operations and parameters
> initEClass(resourceEClass, Resource.class, "Resource",
> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
> ...
> initEReference(getResource_ScheduledActivities(),
> this.getActivityInstance(),
> this.getActivityInstance_AssignedResources(), "scheduledActivities",
> null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
> !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE,
> !IS_DERIVED, IS_ORDERED);
> ...
> initEClass(activityInstanceEClass, ActivityInstance.class,
> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
> IS_GENERATED_INSTANCE_CLASS);
> ...
> initEReference(getActivityInstance_AssignedResources(),
> this.getResource(), this.getResource_ScheduledActivities(),
> "assignedResources", null, 0, -1, ActivityInstance.class, !IS_TRANSIENT,
> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
> ...
> initEReference(getActivityInstance_ProcessInstance(),
> this.getProcessInstance(), this.getProcessInstance_Activities(),
> "processInstance", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT,
> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES,
> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
> ...
> initEClass(processInstanceEClass, ProcessInstance.class,
> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
> IS_GENERATED_INSTANCE_CLASS);
> ...
> initEReference(getProcessInstance_Activities(),
> this.getActivityInstance(), this.getActivityInstance_ProcessInstance(),
> "activities", null, 0, -1, ProcessInstance.class, !IS_TRANSIENT,
> !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
> ...
> }
>
>
> My request is:
> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH r.scheduledActivities
> a LEFT JOIN FETCH a.ProcessInstance where r.id=:id
>
> If I ask to hibernate to print the Sql request, it is pretty good, with
> processInstance data but it is as the mapping doesn't work ???
>
> Before, I have done this request:
> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH r.scheduledActivities
> a where r.id=:id
> As the Fetch is Eager into the description, and then, the sql request
> print by hibernate doesn't contain any ProcessInstance data ...
>
> It is as the container/containment relationship is not understood into
> teneo ...
>
> This is what I try to tell you the first time. Am I more clear now ?
>
> Thank you to have answer so quickly
> Regards
>
> Thomas
>
> Martin Taal a écrit :
>> Hi Thomas,
>> I am not sure that I fully understand what you mean:
>> - do you expect the ProcessInstance to be loaded in the top of the
>> resource?, or
>> - is the processInstance many-to-one not eagerly fetched?
>>
>> Can you post the snippet of the hbm which relates to this?
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Hi All,
>>>
>>> I have a problem with EMF/Teneo and container/containment on relation
>>> with e Fetch Eager
>>>
>>> Here is my relation:
>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>> --(processInstance 0..1)-> ProcessInstance
>>>
>>> scheduledActivities:
>>> *container,containment to false
>>> *EOpposite fill
>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>> cascade=NONE,mappedBy=AssignedResources)
>>>
>>> processInstance:
>>> *container true, containment false
>>> *EOpposite fill
>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>
>>> When I request a resource with its scheduled activities and
>>> processInstances, the result is a Resource, with its scheduled
>>> activities, but without it processInstance (on debug, I see that
>>> their are no eContainer, and the getProcessInstance give the
>>> eContainer).
>>> The Sql request is good when I explicitly ask processInstance, but
>>> not good if I didn't explicitly ask it.
>>> It is as Fetch EAGER doesn't work on container...
>>> Have you ever seen something like that ?
>>> Am I wrong ?
>>> Thanks to help me
>>> Regards
>>>
>>> Thomas
>>>
>>
>>
Re: Fetch Eager and container [message #425862 is a reply to message #425861] Wed, 10 December 2008 10:09 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
The annotation looks good, so I would need to see the hbm to see if something goes wrong there. You
can get the mapping from the datastore doing getMappingXML after the datastore has initialized.

gr. Martin

Thomas wrote:
> By the way, I have forgotten to tell you that we are using the
> EntityManager and to give you some other parts of the ModelPackageImpl:
>
> protected void createTeneoAnnotations() {
> String source = "teneo.hibernate";
> addAnnotation
> (resourceEClass,
> source,
> new String[]
> {
> "appinfo", "@Table(name=\"Oresource\")"
> });
> ....
> addAnnotation
> (getActivityInstance_ProcessInstance(),
> source,
> new String[]
> {
> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
> });
> ....
> addAnnotation
> (getProcessInstance_Activities(),
> source,
> new String[]
> {
> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
> mappedBy=processInstance)"
> });
> ....
> addAnnotation
> (getProcess_Activities(),
> source,
> new String[]
> {
> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
> });
> ....
> }
> protected void createTeneo_1Annotations()
> String source = "teneo.jpa";
> addAnnotation
> (getResource_ScheduledActivities(),
> source,
> new String[]
> {
> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
> cascade=NONE,mappedBy=assignedResources)"
> });
> ....
> addAnnotation
> (getActivityInstance_AssignedResources(),
> source,
> new String[]
> {
> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
> cascade=NONE)"
> });
> ....
> }
>
>
>
>
> Thomas a écrit :
>> Hi Martin,
>>
>> No, the ProcessInstance has to be into the ActivityInstance.
>> Yes, it is the many-to-one that is not fetch eager or fetch within the
>> jpql request.
>> My request is to get a resource, with its ActivityInstance which
>> should contain a ProcessInstance
>> I hope I am clear now ;)
>>
>> How can I have the hbm ? The model is generated
>> I can give you a part of the ModelPackageImpl
>> public void initializePackageContents() {
>> ...
>> // Initialize classes and features; add operations and parameters
>> initEClass(resourceEClass, Resource.class, "Resource",
>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>> ...
>> initEReference(getResource_ScheduledActivities(),
>> this.getActivityInstance(),
>> this.getActivityInstance_AssignedResources(), "scheduledActivities",
>> null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE,
>> IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>> ...
>> initEClass(activityInstanceEClass, ActivityInstance.class,
>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>> IS_GENERATED_INSTANCE_CLASS);
>> ...
>> initEReference(getActivityInstance_AssignedResources(),
>> this.getResource(), this.getResource_ScheduledActivities(),
>> "assignedResources", null, 0, -1, ActivityInstance.class,
>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>> ...
>> initEReference(getActivityInstance_ProcessInstance(),
>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>> "processInstance", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT,
>> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES,
>> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>> ...
>> initEClass(processInstanceEClass, ProcessInstance.class,
>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>> IS_GENERATED_INSTANCE_CLASS);
>> ...
>> initEReference(getProcessInstance_Activities(),
>> this.getActivityInstance(),
>> this.getActivityInstance_ProcessInstance(), "activities", null, 0, -1,
>> ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,
>> IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE,
>> !IS_DERIVED, IS_ORDERED);
>> ...
>> }
>>
>>
>> My request is:
>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where r.id=:id
>>
>> If I ask to hibernate to print the Sql request, it is pretty good,
>> with processInstance data but it is as the mapping doesn't work ???
>>
>> Before, I have done this request:
>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>> r.scheduledActivities a where r.id=:id
>> As the Fetch is Eager into the description, and then, the sql request
>> print by hibernate doesn't contain any ProcessInstance data ...
>>
>> It is as the container/containment relationship is not understood into
>> teneo ...
>>
>> This is what I try to tell you the first time. Am I more clear now ?
>>
>> Thank you to have answer so quickly
>> Regards
>>
>> Thomas
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> I am not sure that I fully understand what you mean:
>>> - do you expect the ProcessInstance to be loaded in the top of the
>>> resource?, or
>>> - is the processInstance many-to-one not eagerly fetched?
>>>
>>> Can you post the snippet of the hbm which relates to this?
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> Hi All,
>>>>
>>>> I have a problem with EMF/Teneo and container/containment on
>>>> relation with e Fetch Eager
>>>>
>>>> Here is my relation:
>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>> --(processInstance 0..1)-> ProcessInstance
>>>>
>>>> scheduledActivities:
>>>> *container,containment to false
>>>> *EOpposite fill
>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>
>>>> processInstance:
>>>> *container true, containment false
>>>> *EOpposite fill
>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>
>>>> When I request a resource with its scheduled activities and
>>>> processInstances, the result is a Resource, with its scheduled
>>>> activities, but without it processInstance (on debug, I see that
>>>> their are no eContainer, and the getProcessInstance give the
>>>> eContainer).
>>>> The Sql request is good when I explicitly ask processInstance, but
>>>> not good if I didn't explicitly ask it.
>>>> It is as Fetch EAGER doesn't work on container...
>>>> Have you ever seen something like that ?
>>>> Am I wrong ?
>>>> Thanks to help me
>>>> Regards
>>>>
>>>> Thomas
>>>>
>>>
>>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Fetch Eager and container [message #425863 is a reply to message #425862] Wed, 10 December 2008 10:28 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
Ok, here it goes.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="false">
<class entity-name="Resource" abstract="false" lazy="false"
discriminator-value="Resource" table="`ORESOURCE`">
<meta attribute="eclassName">Resource</meta>
<meta attribute="epackage">http:///com.oslo.dreams.model</meta>
<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`ID`"/>
<generator class="native"/>
</id>
<discriminator column="`DTYPE`" type="string"/>
<property name="name" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="false" name="`NAME`"/>
</property>
....
<list name="scheduledActivities" lazy="true" table="`RSRC_SCHDLDCTVITIS`">
<key update="true">
<column name="`RESOURCE_ID`" not-null="true" unique="false"/>
</key>
<list-index column="`RSRC_SCHDLDCTVT_DX`"/>
<many-to-many entity-name="ActivityInstance" unique="false"
foreign-key="RSRC_SCHDLDCTVITIS">
<column name="`ACTIVITYINSTNCE_ID`" not-null="true" unique="false"/>
</many-to-many>
</list>
....
</class>
....
<class entity-name="ActivityInstance" abstract="false" lazy="false"
discriminator-value="ActivityInstance" table="`ACTIVITYINSTANCE`">
<meta attribute="eclassName">ActivityInstance</meta>
<meta attribute="epackage">http:///com.oslo.dreams.model</meta>
<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`ID`"/>
<generator class="native"/>
</id>
<discriminator column="`DTYPE`" type="string"/>
....
<list name="assignedResources" lazy="true" table="`ACTVTYNS_SSGNDRSR`">
<key update="true">
<column name="`ACTIVITYINSTANCID`" not-null="true" unique="false"/>
</key>
<list-index column="`ACTVTYN_SSGNDRS_DX`"/>
<many-to-many entity-name="Resource" unique="false"
foreign-key="ACTVTYNS_SSGNDRSR">
<column name="`RESOURCE_ID`" not-null="true" unique="false"/>
</many-to-many>
</list>
....
<many-to-one name="processInstance" entity-name="ProcessInstance"
cascade="refresh" foreign-key="ACTVTYNS_PRCSSNST" lazy="false"
insert="false" update="false" not-null="false">
<column not-null="false" unique="false" name="`ACTVTYN_PRCSSNS_D`"/>
</many-to-one>
....
</class>
....
<class entity-name="ProcessInstance" abstract="false" lazy="false"
discriminator-value="ProcessInstance" table="`PROCESSINSTANCE`">
<meta attribute="eclassName">ProcessInstance</meta>
<meta attribute="epackage">http:///com.oslo.dreams.model</meta>
<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`ID`"/>
<generator class="native"/>
</id>
<discriminator column="`DTYPE`" type="string"/>
....
<list name="activities" lazy="false" cascade="all,delete-orphan">
<key update="true">
<column name="`ACTVTYNS_PRCSSNST`" not-null="false" unique="false"/>
</key>
<list-index column="`PRCSSNSTN_CTVTS_DX`"/>
<one-to-many entity-name="ActivityInstance"/>
</list>
....
</class>

Have you got enough information about the hibernate configuration .

Martin Taal a écrit :
> Hi Thomas,
> The annotation looks good, so I would need to see the hbm to see if
> something goes wrong there. You can get the mapping from the datastore
> doing getMappingXML after the datastore has initialized.
>
> gr. Martin
>
> Thomas wrote:
>> By the way, I have forgotten to tell you that we are using the
>> EntityManager and to give you some other parts of the ModelPackageImpl:
>>
>> protected void createTeneoAnnotations() {
>> String source = "teneo.hibernate"; addAnnotation
>> (resourceEClass,
>> source,
>> new String[]
>> {
>> "appinfo", "@Table(name=\"Oresource\")"
>> }); ....
>> addAnnotation
>> (getActivityInstance_ProcessInstance(),
>> source,
>> new String[]
>> {
>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>> }); ....
>> addAnnotation
>> (getProcessInstance_Activities(),
>> source,
>> new String[]
>> {
>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>> mappedBy=processInstance)"
>> }); ....
>> addAnnotation
>> (getProcess_Activities(),
>> source,
>> new String[]
>> {
>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>> }); ....
>> }
>> protected void createTeneo_1Annotations()
>> String source = "teneo.jpa"; addAnnotation
>> (getResource_ScheduledActivities(),
>> source,
>> new String[]
>> {
>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>> cascade=NONE,mappedBy=assignedResources)"
>> }); ....
>> addAnnotation
>> (getActivityInstance_AssignedResources(),
>> source,
>> new String[]
>> {
>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>> cascade=NONE)"
>> });
>> ....
>> }
>>
>>
>>
>>
>> Thomas a écrit :
>>> Hi Martin,
>>>
>>> No, the ProcessInstance has to be into the ActivityInstance.
>>> Yes, it is the many-to-one that is not fetch eager or fetch within
>>> the jpql request.
>>> My request is to get a resource, with its ActivityInstance which
>>> should contain a ProcessInstance
>>> I hope I am clear now ;)
>>>
>>> How can I have the hbm ? The model is generated
>>> I can give you a part of the ModelPackageImpl
>>> public void initializePackageContents() {
>>> ...
>>> // Initialize classes and features; add operations and
>>> parameters
>>> initEClass(resourceEClass, Resource.class, "Resource",
>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>> ...
>>> initEReference(getResource_ScheduledActivities(),
>>> this.getActivityInstance(),
>>> this.getActivityInstance_AssignedResources(), "scheduledActivities",
>>> null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE,
>>> IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>> ...
>>> initEClass(activityInstanceEClass, ActivityInstance.class,
>>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>> IS_GENERATED_INSTANCE_CLASS);
>>> ...
>>> initEReference(getActivityInstance_AssignedResources(),
>>> this.getResource(), this.getResource_ScheduledActivities(),
>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>> ...
>>> initEReference(getActivityInstance_ProcessInstance(),
>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>> "processInstance", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT,
>>> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES,
>>> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>> ...
>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>> IS_GENERATED_INSTANCE_CLASS);
>>> ...
>>> initEReference(getProcessInstance_Activities(),
>>> this.getActivityInstance(),
>>> this.getActivityInstance_ProcessInstance(), "activities", null, 0,
>>> -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>> ...
>>> }
>>>
>>>
>>> My request is:
>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where r.id=:id
>>>
>>> If I ask to hibernate to print the Sql request, it is pretty good,
>>> with processInstance data but it is as the mapping doesn't work ???
>>>
>>> Before, I have done this request:
>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>> r.scheduledActivities a where r.id=:id
>>> As the Fetch is Eager into the description, and then, the sql request
>>> print by hibernate doesn't contain any ProcessInstance data ...
>>>
>>> It is as the container/containment relationship is not understood
>>> into teneo ...
>>>
>>> This is what I try to tell you the first time. Am I more clear now ?
>>>
>>> Thank you to have answer so quickly
>>> Regards
>>>
>>> Thomas
>>>
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> I am not sure that I fully understand what you mean:
>>>> - do you expect the ProcessInstance to be loaded in the top of the
>>>> resource?, or
>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>
>>>> Can you post the snippet of the hbm which relates to this?
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas wrote:
>>>>> Hi All,
>>>>>
>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>> relation with e Fetch Eager
>>>>>
>>>>> Here is my relation:
>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>
>>>>> scheduledActivities:
>>>>> *container,containment to false
>>>>> *EOpposite fill
>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>
>>>>> processInstance:
>>>>> *container true, containment false
>>>>> *EOpposite fill
>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>
>>>>> When I request a resource with its scheduled activities and
>>>>> processInstances, the result is a Resource, with its scheduled
>>>>> activities, but without it processInstance (on debug, I see that
>>>>> their are no eContainer, and the getProcessInstance give the
>>>>> eContainer).
>>>>> The Sql request is good when I explicitly ask processInstance, but
>>>>> not good if I didn't explicitly ask it.
>>>>> It is as Fetch EAGER doesn't work on container...
>>>>> Have you ever seen something like that ?
>>>>> Am I wrong ?
>>>>> Thanks to help me
>>>>> Regards
>>>>>
>>>>> Thomas
>>>>>
>>>>
>>>>
>
>
Re: Fetch Eager and container [message #425894 is a reply to message #425863] Thu, 11 December 2008 10:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
One thing you can try is to set the annotation: @Fetch(JOIN) on the many to one assocation. I am not
sure if it will work though because the hibernateresource currently uses Hql which does not always
support this setting.
Let me know what you find.

I can easily change the resource topclass loading using criteria queries which apparantly support
fetch=join in the mapping. So if it still does not load eagerly then enter a bugzilla and I will
take care of it.

gr. Martin

Thomas wrote:
> Ok, here it goes.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <hibernate-mapping auto-import="false">
> <class entity-name="Resource" abstract="false" lazy="false"
> discriminator-value="Resource" table="`ORESOURCE`">
> <meta attribute="eclassName">Resource</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="true" unique="false" name="`NAME`"/>
> </property>
> ....
> <list name="scheduledActivities" lazy="true"
> table="`RSRC_SCHDLDCTVITIS`">
> <key update="true">
> <column name="`RESOURCE_ID`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
> <many-to-many entity-name="ActivityInstance" unique="false"
> foreign-key="RSRC_SCHDLDCTVITIS">
> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> ....
> </class>
> ....
> <class entity-name="ActivityInstance" abstract="false" lazy="false"
> discriminator-value="ActivityInstance" table="`ACTIVITYINSTANCE`">
> <meta attribute="eclassName">ActivityInstance</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> ....
> <list name="assignedResources" lazy="true"
> table="`ACTVTYNS_SSGNDRSR`">
> <key update="true">
> <column name="`ACTIVITYINSTANCID`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
> <many-to-many entity-name="Resource" unique="false"
> foreign-key="ACTVTYNS_SSGNDRSR">
> <column name="`RESOURCE_ID`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> ....
> <many-to-one name="processInstance"
> entity-name="ProcessInstance" cascade="refresh"
> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
> update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`ACTVTYN_PRCSSNS_D`"/>
> </many-to-one>
> ....
> </class>
> ....
> <class entity-name="ProcessInstance" abstract="false" lazy="false"
> discriminator-value="ProcessInstance" table="`PROCESSINSTANCE`">
> <meta attribute="eclassName">ProcessInstance</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> ....
> <list name="activities" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
> <one-to-many entity-name="ActivityInstance"/>
> </list>
> ....
> </class>
>
> Have you got enough information about the hibernate configuration .
>
> Martin Taal a écrit :
>> Hi Thomas,
>> The annotation looks good, so I would need to see the hbm to see if
>> something goes wrong there. You can get the mapping from the datastore
>> doing getMappingXML after the datastore has initialized.
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> By the way, I have forgotten to tell you that we are using the
>>> EntityManager and to give you some other parts of the ModelPackageImpl:
>>>
>>> protected void createTeneoAnnotations() {
>>> String source = "teneo.hibernate"; addAnnotation
>>> (resourceEClass,
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@Table(name=\"Oresource\")"
>>> }); ....
>>> addAnnotation
>>> (getActivityInstance_ProcessInstance(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>> }); ....
>>> addAnnotation
>>> (getProcessInstance_Activities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>> mappedBy=processInstance)"
>>> }); ....
>>> addAnnotation
>>> (getProcess_Activities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>> }); ....
>>> }
>>> protected void createTeneo_1Annotations()
>>> String source = "teneo.jpa"; addAnnotation
>>> (getResource_ScheduledActivities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>> cascade=NONE,mappedBy=assignedResources)"
>>> }); ....
>>> addAnnotation
>>> (getActivityInstance_AssignedResources(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>> cascade=NONE)"
>>> });
>>> ....
>>> }
>>>
>>>
>>>
>>>
>>> Thomas a écrit :
>>>> Hi Martin,
>>>>
>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>> Yes, it is the many-to-one that is not fetch eager or fetch within
>>>> the jpql request.
>>>> My request is to get a resource, with its ActivityInstance which
>>>> should contain a ProcessInstance
>>>> I hope I am clear now ;)
>>>>
>>>> How can I have the hbm ? The model is generated
>>>> I can give you a part of the ModelPackageImpl
>>>> public void initializePackageContents() {
>>>> ...
>>>> // Initialize classes and features; add operations and
>>>> parameters
>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getResource_ScheduledActivities(),
>>>> this.getActivityInstance(),
>>>> this.getActivityInstance_AssignedResources(), "scheduledActivities",
>>>> null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>> IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>> ...
>>>> initEClass(activityInstanceEClass, ActivityInstance.class,
>>>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>> IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getActivityInstance_AssignedResources(),
>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>> IS_ORDERED);
>>>> ...
>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>> IS_ORDERED);
>>>> ...
>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>> IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getProcessInstance_Activities(),
>>>> this.getActivityInstance(),
>>>> this.getActivityInstance_ProcessInstance(), "activities", null, 0,
>>>> -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>> ...
>>>> }
>>>>
>>>>
>>>> My request is:
>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>> r.id=:id
>>>>
>>>> If I ask to hibernate to print the Sql request, it is pretty good,
>>>> with processInstance data but it is as the mapping doesn't work ???
>>>>
>>>> Before, I have done this request:
>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>> r.scheduledActivities a where r.id=:id
>>>> As the Fetch is Eager into the description, and then, the sql
>>>> request print by hibernate doesn't contain any ProcessInstance data ...
>>>>
>>>> It is as the container/containment relationship is not understood
>>>> into teneo ...
>>>>
>>>> This is what I try to tell you the first time. Am I more clear now ?
>>>>
>>>> Thank you to have answer so quickly
>>>> Regards
>>>>
>>>> Thomas
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> I am not sure that I fully understand what you mean:
>>>>> - do you expect the ProcessInstance to be loaded in the top of the
>>>>> resource?, or
>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>
>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> Hi All,
>>>>>>
>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>> relation with e Fetch Eager
>>>>>>
>>>>>> Here is my relation:
>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>
>>>>>> scheduledActivities:
>>>>>> *container,containment to false
>>>>>> *EOpposite fill
>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>
>>>>>> processInstance:
>>>>>> *container true, containment false
>>>>>> *EOpposite fill
>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>
>>>>>> When I request a resource with its scheduled activities and
>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>> activities, but without it processInstance (on debug, I see that
>>>>>> their are no eContainer, and the getProcessInstance give the
>>>>>> eContainer).
>>>>>> The Sql request is good when I explicitly ask processInstance, but
>>>>>> not good if I didn't explicitly ask it.
>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>> Have you ever seen something like that ?
>>>>>> Am I wrong ?
>>>>>> Thanks to help me
>>>>>> Regards
>>>>>>
>>>>>> Thomas
>>>>>>
>>>>>
>>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Fetch Eager and container [message #425895 is a reply to message #425863] Thu, 11 December 2008 10:09 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
I think, it is the EOpposite that doesn't work with Teneo/Hibernate
I have strengthened my constraints, and so, I have found that my insert
are not complete. The column of relation is not inserted into database.
It is not declared into the all column of the sql request AS hibernate
add weel the constraint on database creation !!!!!!!!
It is amazing. Is it a well known bug or miss use ???

Thomas a écrit :
> Ok, here it goes.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <hibernate-mapping auto-import="false">
> <class entity-name="Resource" abstract="false" lazy="false"
> discriminator-value="Resource" table="`ORESOURCE`">
> <meta attribute="eclassName">Resource</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> <property name="name" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="true" unique="false" name="`NAME`"/>
> </property>
> ...
> <list name="scheduledActivities" lazy="true"
> table="`RSRC_SCHDLDCTVITIS`">
> <key update="true">
> <column name="`RESOURCE_ID`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
> <many-to-many entity-name="ActivityInstance" unique="false"
> foreign-key="RSRC_SCHDLDCTVITIS">
> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> ...
> </class>
> ...
> <class entity-name="ActivityInstance" abstract="false" lazy="false"
> discriminator-value="ActivityInstance" table="`ACTIVITYINSTANCE`">
> <meta attribute="eclassName">ActivityInstance</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> ...
> <list name="assignedResources" lazy="true"
> table="`ACTVTYNS_SSGNDRSR`">
> <key update="true">
> <column name="`ACTIVITYINSTANCID`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
> <many-to-many entity-name="Resource" unique="false"
> foreign-key="ACTVTYNS_SSGNDRSR">
> <column name="`RESOURCE_ID`" not-null="true"
> unique="false"/>
> </many-to-many>
> </list>
> ...
> <many-to-one name="processInstance"
> entity-name="ProcessInstance" cascade="refresh"
> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
> update="false" not-null="false">
> <column not-null="false" unique="false"
> name="`ACTVTYN_PRCSSNS_D`"/>
> </many-to-one>
> ...
> </class>
> ...
> <class entity-name="ProcessInstance" abstract="false" lazy="false"
> discriminator-value="ProcessInstance" table="`PROCESSINSTANCE`">
> <meta attribute="eclassName">ProcessInstance</meta>
> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
> <id name="id" type="long" unsaved-value="0">
> <column not-null="true" unique="false" name="`ID`"/>
> <generator class="native"/>
> </id>
> <discriminator column="`DTYPE`" type="string"/>
> ...
> <list name="activities" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
> unique="false"/>
> </key>
> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
> <one-to-many entity-name="ActivityInstance"/>
> </list>
> ...
> </class>
>
> Have you got enough information about the hibernate configuration .
>
> Martin Taal a écrit :
>> Hi Thomas,
>> The annotation looks good, so I would need to see the hbm to see if
>> something goes wrong there. You can get the mapping from the datastore
>> doing getMappingXML after the datastore has initialized.
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> By the way, I have forgotten to tell you that we are using the
>>> EntityManager and to give you some other parts of the ModelPackageImpl:
>>>
>>> protected void createTeneoAnnotations() {
>>> String source = "teneo.hibernate"; addAnnotation
>>> (resourceEClass,
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@Table(name=\"Oresource\")"
>>> }); ....
>>> addAnnotation
>>> (getActivityInstance_ProcessInstance(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>> }); ....
>>> addAnnotation
>>> (getProcessInstance_Activities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>> mappedBy=processInstance)"
>>> }); ....
>>> addAnnotation
>>> (getProcess_Activities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>> }); ....
>>> }
>>> protected void createTeneo_1Annotations()
>>> String source = "teneo.jpa"; addAnnotation
>>> (getResource_ScheduledActivities(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>> cascade=NONE,mappedBy=assignedResources)"
>>> }); ....
>>> addAnnotation
>>> (getActivityInstance_AssignedResources(),
>>> source,
>>> new String[]
>>> {
>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>> cascade=NONE)"
>>> });
>>> ....
>>> }
>>>
>>>
>>>
>>>
>>> Thomas a écrit :
>>>> Hi Martin,
>>>>
>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>> Yes, it is the many-to-one that is not fetch eager or fetch within
>>>> the jpql request.
>>>> My request is to get a resource, with its ActivityInstance which
>>>> should contain a ProcessInstance
>>>> I hope I am clear now ;)
>>>>
>>>> How can I have the hbm ? The model is generated
>>>> I can give you a part of the ModelPackageImpl
>>>> public void initializePackageContents() {
>>>> ...
>>>> // Initialize classes and features; add operations and
>>>> parameters
>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getResource_ScheduledActivities(),
>>>> this.getActivityInstance(),
>>>> this.getActivityInstance_AssignedResources(), "scheduledActivities",
>>>> null, 0, -1, Resource.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>> IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>> ...
>>>> initEClass(activityInstanceEClass, ActivityInstance.class,
>>>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>> IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getActivityInstance_AssignedResources(),
>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>> IS_ORDERED);
>>>> ...
>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>> IS_ORDERED);
>>>> ...
>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>> IS_GENERATED_INSTANCE_CLASS);
>>>> ...
>>>> initEReference(getProcessInstance_Activities(),
>>>> this.getActivityInstance(),
>>>> this.getActivityInstance_ProcessInstance(), "activities", null, 0,
>>>> -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>> ...
>>>> }
>>>>
>>>>
>>>> My request is:
>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>> r.id=:id
>>>>
>>>> If I ask to hibernate to print the Sql request, it is pretty good,
>>>> with processInstance data but it is as the mapping doesn't work ???
>>>>
>>>> Before, I have done this request:
>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>> r.scheduledActivities a where r.id=:id
>>>> As the Fetch is Eager into the description, and then, the sql
>>>> request print by hibernate doesn't contain any ProcessInstance data ...
>>>>
>>>> It is as the container/containment relationship is not understood
>>>> into teneo ...
>>>>
>>>> This is what I try to tell you the first time. Am I more clear now ?
>>>>
>>>> Thank you to have answer so quickly
>>>> Regards
>>>>
>>>> Thomas
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> I am not sure that I fully understand what you mean:
>>>>> - do you expect the ProcessInstance to be loaded in the top of the
>>>>> resource?, or
>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>
>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> Hi All,
>>>>>>
>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>> relation with e Fetch Eager
>>>>>>
>>>>>> Here is my relation:
>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>
>>>>>> scheduledActivities:
>>>>>> *container,containment to false
>>>>>> *EOpposite fill
>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>
>>>>>> processInstance:
>>>>>> *container true, containment false
>>>>>> *EOpposite fill
>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>
>>>>>> When I request a resource with its scheduled activities and
>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>> activities, but without it processInstance (on debug, I see that
>>>>>> their are no eContainer, and the getProcessInstance give the
>>>>>> eContainer).
>>>>>> The Sql request is good when I explicitly ask processInstance, but
>>>>>> not good if I didn't explicitly ask it.
>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>> Have you ever seen something like that ?
>>>>>> Am I wrong ?
>>>>>> Thanks to help me
>>>>>> Regards
>>>>>>
>>>>>> Thomas
>>>>>>
>>>>>
>>>>>
>>
>>
Re: Fetch Eager and container [message #425896 is a reply to message #425895] Thu, 11 December 2008 10:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
Do you mean the processInstance feature/column/property?
is processInstance the opposite of activities? Because the strange thing is that they map to
different columns: ACTVTYN_PRCSSNS_D and ACTVTYN_PRCSSNS.

Note that something which plays a role here is that activities is an indexed collection. Teneo maps
it so that the column to store this association is controlled from the activities side. See this
chapter in the hibernate manual why this is done like this:
Bidirectional associations with indexed collections

If the order is not important then you can make the activities collection non-indexed by doing
@OneToMany(indexed=false)

Then the mapping will be different. Also adding a @JoinTable annotation makes the mapping different
(although then you will have a join table).

But again I find it strange that the columns on both sides of the associations are different.

gr. Martin

Thomas wrote:
> I think, it is the EOpposite that doesn't work with Teneo/Hibernate
> I have strengthened my constraints, and so, I have found that my insert
> are not complete. The column of relation is not inserted into database.
> It is not declared into the all column of the sql request AS hibernate
> add weel the constraint on database creation !!!!!!!!
> It is amazing. Is it a well known bug or miss use ???
>
> Thomas a écrit :
>> Ok, here it goes.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
>> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>
>> <hibernate-mapping auto-import="false">
>> <class entity-name="Resource" abstract="false" lazy="false"
>> discriminator-value="Resource" table="`ORESOURCE`">
>> <meta attribute="eclassName">Resource</meta>
>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>> <id name="id" type="long" unsaved-value="0">
>> <column not-null="true" unique="false" name="`ID`"/>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`DTYPE`" type="string"/>
>> <property name="name" lazy="false" insert="true" update="true"
>> not-null="true" unique="false" type="java.lang.String">
>> <column not-null="true" unique="false" name="`NAME`"/>
>> </property>
>> ...
>> <list name="scheduledActivities" lazy="true"
>> table="`RSRC_SCHDLDCTVITIS`">
>> <key update="true">
>> <column name="`RESOURCE_ID`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
>> <many-to-many entity-name="ActivityInstance"
>> unique="false" foreign-key="RSRC_SCHDLDCTVITIS">
>> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> ...
>> </class>
>> ...
>> <class entity-name="ActivityInstance" abstract="false"
>> lazy="false" discriminator-value="ActivityInstance"
>> table="`ACTIVITYINSTANCE`">
>> <meta attribute="eclassName">ActivityInstance</meta>
>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>> <id name="id" type="long" unsaved-value="0">
>> <column not-null="true" unique="false" name="`ID`"/>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`DTYPE`" type="string"/>
>> ...
>> <list name="assignedResources" lazy="true"
>> table="`ACTVTYNS_SSGNDRSR`">
>> <key update="true">
>> <column name="`ACTIVITYINSTANCID`" not-null="true"
>> unique="false"/>
>> </key>
>> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
>> <many-to-many entity-name="Resource" unique="false"
>> foreign-key="ACTVTYNS_SSGNDRSR">
>> <column name="`RESOURCE_ID`" not-null="true"
>> unique="false"/>
>> </many-to-many>
>> </list>
>> ...
>> <many-to-one name="processInstance"
>> entity-name="ProcessInstance" cascade="refresh"
>> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
>> update="false" not-null="false">
>> <column not-null="false" unique="false"
>> name="`ACTVTYN_PRCSSNS_D`"/>
>> </many-to-one>
>> ...
>> </class>
>> ...
>> <class entity-name="ProcessInstance" abstract="false" lazy="false"
>> discriminator-value="ProcessInstance" table="`PROCESSINSTANCE`">
>> <meta attribute="eclassName">ProcessInstance</meta>
>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>> <id name="id" type="long" unsaved-value="0">
>> <column not-null="true" unique="false" name="`ID`"/>
>> <generator class="native"/>
>> </id>
>> <discriminator column="`DTYPE`" type="string"/>
>> ...
>> <list name="activities" lazy="false" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
>> unique="false"/>
>> </key>
>> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
>> <one-to-many entity-name="ActivityInstance"/>
>> </list>
>> ...
>> </class>
>>
>> Have you got enough information about the hibernate configuration .
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> The annotation looks good, so I would need to see the hbm to see if
>>> something goes wrong there. You can get the mapping from the
>>> datastore doing getMappingXML after the datastore has initialized.
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> By the way, I have forgotten to tell you that we are using the
>>>> EntityManager and to give you some other parts of the ModelPackageImpl:
>>>>
>>>> protected void createTeneoAnnotations() {
>>>> String source = "teneo.hibernate"; addAnnotation
>>>> (resourceEClass,
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@Table(name=\"Oresource\")"
>>>> }); ....
>>>> addAnnotation
>>>> (getActivityInstance_ProcessInstance(),
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>>> }); ....
>>>> addAnnotation
>>>> (getProcessInstance_Activities(),
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>>> mappedBy=processInstance)"
>>>> }); ....
>>>> addAnnotation
>>>> (getProcess_Activities(),
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>>> }); ....
>>>> }
>>>> protected void createTeneo_1Annotations()
>>>> String source = "teneo.jpa";
>>>> addAnnotation
>>>> (getResource_ScheduledActivities(),
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>> cascade=NONE,mappedBy=assignedResources)"
>>>> }); ....
>>>> addAnnotation
>>>> (getActivityInstance_AssignedResources(),
>>>> source,
>>>> new String[]
>>>> {
>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>> cascade=NONE)"
>>>> });
>>>> ....
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> Thomas a écrit :
>>>>> Hi Martin,
>>>>>
>>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>>> Yes, it is the many-to-one that is not fetch eager or fetch within
>>>>> the jpql request.
>>>>> My request is to get a resource, with its ActivityInstance which
>>>>> should contain a ProcessInstance
>>>>> I hope I am clear now ;)
>>>>>
>>>>> How can I have the hbm ? The model is generated
>>>>> I can give you a part of the ModelPackageImpl
>>>>> public void initializePackageContents() {
>>>>> ...
>>>>> // Initialize classes and features; add operations and
>>>>> parameters
>>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>> ...
>>>>> initEReference(getResource_ScheduledActivities(),
>>>>> this.getActivityInstance(),
>>>>> this.getActivityInstance_AssignedResources(),
>>>>> "scheduledActivities", null, 0, -1, Resource.class, !IS_TRANSIENT,
>>>>> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
>>>>> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>> ...
>>>>> initEClass(activityInstanceEClass, ActivityInstance.class,
>>>>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>> ...
>>>>> initEReference(getActivityInstance_AssignedResources(),
>>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>> IS_ORDERED);
>>>>> ...
>>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>> IS_ORDERED);
>>>>> ...
>>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>> ...
>>>>> initEReference(getProcessInstance_Activities(),
>>>>> this.getActivityInstance(),
>>>>> this.getActivityInstance_ProcessInstance(), "activities", null, 0,
>>>>> -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>> ...
>>>>> }
>>>>>
>>>>>
>>>>> My request is:
>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>>> r.id=:id
>>>>>
>>>>> If I ask to hibernate to print the Sql request, it is pretty good,
>>>>> with processInstance data but it is as the mapping doesn't work ???
>>>>>
>>>>> Before, I have done this request:
>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>> r.scheduledActivities a where r.id=:id
>>>>> As the Fetch is Eager into the description, and then, the sql
>>>>> request print by hibernate doesn't contain any ProcessInstance data
>>>>> ...
>>>>>
>>>>> It is as the container/containment relationship is not understood
>>>>> into teneo ...
>>>>>
>>>>> This is what I try to tell you the first time. Am I more clear now ?
>>>>>
>>>>> Thank you to have answer so quickly
>>>>> Regards
>>>>>
>>>>> Thomas
>>>>>
>>>>> Martin Taal a écrit :
>>>>>> Hi Thomas,
>>>>>> I am not sure that I fully understand what you mean:
>>>>>> - do you expect the ProcessInstance to be loaded in the top of the
>>>>>> resource?, or
>>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>>
>>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Thomas wrote:
>>>>>>> Hi All,
>>>>>>>
>>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>>> relation with e Fetch Eager
>>>>>>>
>>>>>>> Here is my relation:
>>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>>
>>>>>>> scheduledActivities:
>>>>>>> *container,containment to false
>>>>>>> *EOpposite fill
>>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>>
>>>>>>> processInstance:
>>>>>>> *container true, containment false
>>>>>>> *EOpposite fill
>>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>>
>>>>>>> When I request a resource with its scheduled activities and
>>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>>> activities, but without it processInstance (on debug, I see that
>>>>>>> their are no eContainer, and the getProcessInstance give the
>>>>>>> eContainer).
>>>>>>> The Sql request is good when I explicitly ask processInstance,
>>>>>>> but not good if I didn't explicitly ask it.
>>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>>> Have you ever seen something like that ?
>>>>>>> Am I wrong ?
>>>>>>> Thanks to help me
>>>>>>> Regards
>>>>>>>
>>>>>>> Thomas
>>>>>>>
>>>>>>
>>>>>>
>>>
>>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Fetch Eager and container [message #425902 is a reply to message #425896] Thu, 11 December 2008 14:13 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
Yes, you have seen well, processInstance is the opposite of activities,
and it is really strange this double naming.
Is the EOpposite compatible with the mappedBy of JPA ? Who should manage
the bidirectionality of the relation ?

Here, the order is important.

Martin Taal a écrit :
> Hi Thomas,
> Do you mean the processInstance feature/column/property?
> is processInstance the opposite of activities? Because the strange thing
> is that they map to different columns: ACTVTYN_PRCSSNS_D and
> ACTVTYN_PRCSSNS.
>
> Note that something which plays a role here is that activities is an
> indexed collection. Teneo maps it so that the column to store this
> association is controlled from the activities side. See this chapter in
> the hibernate manual why this is done like this:
> Bidirectional associations with indexed collections
>
> If the order is not important then you can make the activities
> collection non-indexed by doing
> @OneToMany(indexed=false)
>
> Then the mapping will be different. Also adding a @JoinTable annotation
> makes the mapping different (although then you will have a join table).
>
> But again I find it strange that the columns on both sides of the
> associations are different.
>
> gr. Martin
>
> Thomas wrote:
>> I think, it is the EOpposite that doesn't work with Teneo/Hibernate
>> I have strengthened my constraints, and so, I have found that my
>> insert are not complete. The column of relation is not inserted into
>> database.
>> It is not declared into the all column of the sql request AS hibernate
>> add weel the constraint on database creation !!!!!!!!
>> It is amazing. Is it a well known bug or miss use ???
>>
>> Thomas a écrit :
>>> Ok, here it goes.
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>> DTD 3.0//EN"
>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>>
>>> <hibernate-mapping auto-import="false">
>>> <class entity-name="Resource" abstract="false" lazy="false"
>>> discriminator-value="Resource" table="`ORESOURCE`">
>>> <meta attribute="eclassName">Resource</meta>
>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>> <id name="id" type="long" unsaved-value="0">
>>> <column not-null="true" unique="false" name="`ID`"/>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`DTYPE`" type="string"/>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="true" unique="false" type="java.lang.String">
>>> <column not-null="true" unique="false" name="`NAME`"/>
>>> </property>
>>> ...
>>> <list name="scheduledActivities" lazy="true"
>>> table="`RSRC_SCHDLDCTVITIS`">
>>> <key update="true">
>>> <column name="`RESOURCE_ID`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
>>> <many-to-many entity-name="ActivityInstance"
>>> unique="false" foreign-key="RSRC_SCHDLDCTVITIS">
>>> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> ...
>>> </class>
>>> ...
>>> <class entity-name="ActivityInstance" abstract="false"
>>> lazy="false" discriminator-value="ActivityInstance"
>>> table="`ACTIVITYINSTANCE`">
>>> <meta attribute="eclassName">ActivityInstance</meta>
>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>> <id name="id" type="long" unsaved-value="0">
>>> <column not-null="true" unique="false" name="`ID`"/>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`DTYPE`" type="string"/>
>>> ...
>>> <list name="assignedResources" lazy="true"
>>> table="`ACTVTYNS_SSGNDRSR`">
>>> <key update="true">
>>> <column name="`ACTIVITYINSTANCID`" not-null="true"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
>>> <many-to-many entity-name="Resource" unique="false"
>>> foreign-key="ACTVTYNS_SSGNDRSR">
>>> <column name="`RESOURCE_ID`" not-null="true"
>>> unique="false"/>
>>> </many-to-many>
>>> </list>
>>> ...
>>> <many-to-one name="processInstance"
>>> entity-name="ProcessInstance" cascade="refresh"
>>> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
>>> update="false" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`ACTVTYN_PRCSSNS_D`"/>
>>> </many-to-one>
>>> ...
>>> </class>
>>> ...
>>> <class entity-name="ProcessInstance" abstract="false"
>>> lazy="false" discriminator-value="ProcessInstance"
>>> table="`PROCESSINSTANCE`">
>>> <meta attribute="eclassName">ProcessInstance</meta>
>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>> <id name="id" type="long" unsaved-value="0">
>>> <column not-null="true" unique="false" name="`ID`"/>
>>> <generator class="native"/>
>>> </id>
>>> <discriminator column="`DTYPE`" type="string"/>
>>> ...
>>> <list name="activities" lazy="false"
>>> cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
>>> unique="false"/>
>>> </key>
>>> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
>>> <one-to-many entity-name="ActivityInstance"/>
>>> </list>
>>> ...
>>> </class>
>>>
>>> Have you got enough information about the hibernate configuration .
>>>
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> The annotation looks good, so I would need to see the hbm to see if
>>>> something goes wrong there. You can get the mapping from the
>>>> datastore doing getMappingXML after the datastore has initialized.
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas wrote:
>>>>> By the way, I have forgotten to tell you that we are using the
>>>>> EntityManager and to give you some other parts of the
>>>>> ModelPackageImpl:
>>>>>
>>>>> protected void createTeneoAnnotations() {
>>>>> String source = "teneo.hibernate"; addAnnotation
>>>>> (resourceEClass,
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@Table(name=\"Oresource\")"
>>>>> }); ....
>>>>> addAnnotation
>>>>> (getActivityInstance_ProcessInstance(),
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>>>> }); ....
>>>>> addAnnotation
>>>>> (getProcessInstance_Activities(),
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>>>> mappedBy=processInstance)"
>>>>> }); ....
>>>>> addAnnotation
>>>>> (getProcess_Activities(),
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>>>> }); ....
>>>>> }
>>>>> protected void createTeneo_1Annotations()
>>>>> String source = "teneo.jpa";
>>>>> addAnnotation
>>>>> (getResource_ScheduledActivities(),
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>> cascade=NONE,mappedBy=assignedResources)"
>>>>> }); ....
>>>>> addAnnotation
>>>>> (getActivityInstance_AssignedResources(),
>>>>> source,
>>>>> new String[]
>>>>> {
>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>> cascade=NONE)"
>>>>> });
>>>>> ....
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thomas a écrit :
>>>>>> Hi Martin,
>>>>>>
>>>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>>>> Yes, it is the many-to-one that is not fetch eager or fetch within
>>>>>> the jpql request.
>>>>>> My request is to get a resource, with its ActivityInstance which
>>>>>> should contain a ProcessInstance
>>>>>> I hope I am clear now ;)
>>>>>>
>>>>>> How can I have the hbm ? The model is generated
>>>>>> I can give you a part of the ModelPackageImpl
>>>>>> public void initializePackageContents() {
>>>>>> ...
>>>>>> // Initialize classes and features; add operations and
>>>>>> parameters
>>>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>>> ...
>>>>>> initEReference(getResource_ScheduledActivities(),
>>>>>> this.getActivityInstance(),
>>>>>> this.getActivityInstance_AssignedResources(),
>>>>>> "scheduledActivities", null, 0, -1, Resource.class, !IS_TRANSIENT,
>>>>>> !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
>>>>>> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>>> ...
>>>>>> initEClass(activityInstanceEClass, ActivityInstance.class,
>>>>>> "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>>> ...
>>>>>> initEReference(getActivityInstance_AssignedResources(),
>>>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>> IS_ORDERED);
>>>>>> ...
>>>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>> IS_ORDERED);
>>>>>> ...
>>>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>>> ...
>>>>>> initEReference(getProcessInstance_Activities(),
>>>>>> this.getActivityInstance(),
>>>>>> this.getActivityInstance_ProcessInstance(), "activities", null, 0,
>>>>>> -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>>
>>>>>> My request is:
>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>>>> r.id=:id
>>>>>>
>>>>>> If I ask to hibernate to print the Sql request, it is pretty good,
>>>>>> with processInstance data but it is as the mapping doesn't work ???
>>>>>>
>>>>>> Before, I have done this request:
>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>> r.scheduledActivities a where r.id=:id
>>>>>> As the Fetch is Eager into the description, and then, the sql
>>>>>> request print by hibernate doesn't contain any ProcessInstance
>>>>>> data ...
>>>>>>
>>>>>> It is as the container/containment relationship is not understood
>>>>>> into teneo ...
>>>>>>
>>>>>> This is what I try to tell you the first time. Am I more clear now ?
>>>>>>
>>>>>> Thank you to have answer so quickly
>>>>>> Regards
>>>>>>
>>>>>> Thomas
>>>>>>
>>>>>> Martin Taal a écrit :
>>>>>>> Hi Thomas,
>>>>>>> I am not sure that I fully understand what you mean:
>>>>>>> - do you expect the ProcessInstance to be loaded in the top of
>>>>>>> the resource?, or
>>>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>>>
>>>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Thomas wrote:
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>>>> relation with e Fetch Eager
>>>>>>>>
>>>>>>>> Here is my relation:
>>>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>>>
>>>>>>>> scheduledActivities:
>>>>>>>> *container,containment to false
>>>>>>>> *EOpposite fill
>>>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>>>
>>>>>>>> processInstance:
>>>>>>>> *container true, containment false
>>>>>>>> *EOpposite fill
>>>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>>>
>>>>>>>> When I request a resource with its scheduled activities and
>>>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>>>> activities, but without it processInstance (on debug, I see that
>>>>>>>> their are no eContainer, and the getProcessInstance give the
>>>>>>>> eContainer).
>>>>>>>> The Sql request is good when I explicitly ask processInstance,
>>>>>>>> but not good if I didn't explicitly ask it.
>>>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>>>> Have you ever seen something like that ?
>>>>>>>> Am I wrong ?
>>>>>>>> Thanks to help me
>>>>>>>> Regards
>>>>>>>>
>>>>>>>> Thomas
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>
>>>>
>
>
Re: Fetch Eager and container [message #426148 is a reply to message #425902] Wed, 17 December 2008 10:33 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 37
Registered: July 2009
Member
I took a lot of time to find a good way for my project.
the EOpposite give us a lot of problems one a relation
manyToOne/OneToMany declared on jpa.
as in jpa it is already declared, I forgive the emf EOpposite property
and it works fine.
on a ManyToMany relation, it seems work fine.

Thomas a écrit :
> Yes, you have seen well, processInstance is the opposite of activities,
> and it is really strange this double naming.
> Is the EOpposite compatible with the mappedBy of JPA ? Who should manage
> the bidirectionality of the relation ?
>
> Here, the order is important.
>
> Martin Taal a écrit :
>> Hi Thomas,
>> Do you mean the processInstance feature/column/property?
>> is processInstance the opposite of activities? Because the strange
>> thing is that they map to different columns: ACTVTYN_PRCSSNS_D and
>> ACTVTYN_PRCSSNS.
>>
>> Note that something which plays a role here is that activities is an
>> indexed collection. Teneo maps it so that the column to store this
>> association is controlled from the activities side. See this chapter
>> in the hibernate manual why this is done like this:
>> Bidirectional associations with indexed collections
>>
>> If the order is not important then you can make the activities
>> collection non-indexed by doing
>> @OneToMany(indexed=false)
>>
>> Then the mapping will be different. Also adding a @JoinTable
>> annotation makes the mapping different (although then you will have a
>> join table).
>>
>> But again I find it strange that the columns on both sides of the
>> associations are different.
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> I think, it is the EOpposite that doesn't work with Teneo/Hibernate
>>> I have strengthened my constraints, and so, I have found that my
>>> insert are not complete. The column of relation is not inserted into
>>> database.
>>> It is not declared into the all column of the sql request AS
>>> hibernate add weel the constraint on database creation !!!!!!!!
>>> It is amazing. Is it a well known bug or miss use ???
>>>
>>> Thomas a écrit :
>>>> Ok, here it goes.
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>>> DTD 3.0//EN"
>>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>>>
>>>> <hibernate-mapping auto-import="false">
>>>> <class entity-name="Resource" abstract="false" lazy="false"
>>>> discriminator-value="Resource" table="`ORESOURCE`">
>>>> <meta attribute="eclassName">Resource</meta>
>>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>> <id name="id" type="long" unsaved-value="0">
>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`DTYPE`" type="string"/>
>>>> <property name="name" lazy="false" insert="true"
>>>> update="true" not-null="true" unique="false" type="java.lang.String">
>>>> <column not-null="true" unique="false" name="`NAME`"/>
>>>> </property>
>>>> ...
>>>> <list name="scheduledActivities" lazy="true"
>>>> table="`RSRC_SCHDLDCTVITIS`">
>>>> <key update="true">
>>>> <column name="`RESOURCE_ID`" not-null="true"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
>>>> <many-to-many entity-name="ActivityInstance"
>>>> unique="false" foreign-key="RSRC_SCHDLDCTVITIS">
>>>> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
>>>> unique="false"/>
>>>> </many-to-many>
>>>> </list>
>>>> ...
>>>> </class>
>>>> ...
>>>> <class entity-name="ActivityInstance" abstract="false"
>>>> lazy="false" discriminator-value="ActivityInstance"
>>>> table="`ACTIVITYINSTANCE`">
>>>> <meta attribute="eclassName">ActivityInstance</meta>
>>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>> <id name="id" type="long" unsaved-value="0">
>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`DTYPE`" type="string"/>
>>>> ...
>>>> <list name="assignedResources" lazy="true"
>>>> table="`ACTVTYNS_SSGNDRSR`">
>>>> <key update="true">
>>>> <column name="`ACTIVITYINSTANCID`" not-null="true"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
>>>> <many-to-many entity-name="Resource" unique="false"
>>>> foreign-key="ACTVTYNS_SSGNDRSR">
>>>> <column name="`RESOURCE_ID`" not-null="true"
>>>> unique="false"/>
>>>> </many-to-many>
>>>> </list>
>>>> ...
>>>> <many-to-one name="processInstance"
>>>> entity-name="ProcessInstance" cascade="refresh"
>>>> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
>>>> update="false" not-null="false">
>>>> <column not-null="false" unique="false"
>>>> name="`ACTVTYN_PRCSSNS_D`"/>
>>>> </many-to-one>
>>>> ...
>>>> </class>
>>>> ...
>>>> <class entity-name="ProcessInstance" abstract="false"
>>>> lazy="false" discriminator-value="ProcessInstance"
>>>> table="`PROCESSINSTANCE`">
>>>> <meta attribute="eclassName">ProcessInstance</meta>
>>>> <meta attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>> <id name="id" type="long" unsaved-value="0">
>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>> <generator class="native"/>
>>>> </id>
>>>> <discriminator column="`DTYPE`" type="string"/>
>>>> ...
>>>> <list name="activities" lazy="false"
>>>> cascade="all,delete-orphan">
>>>> <key update="true">
>>>> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
>>>> unique="false"/>
>>>> </key>
>>>> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
>>>> <one-to-many entity-name="ActivityInstance"/>
>>>> </list>
>>>> ...
>>>> </class>
>>>>
>>>> Have you got enough information about the hibernate configuration .
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> The annotation looks good, so I would need to see the hbm to see if
>>>>> something goes wrong there. You can get the mapping from the
>>>>> datastore doing getMappingXML after the datastore has initialized.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> By the way, I have forgotten to tell you that we are using the
>>>>>> EntityManager and to give you some other parts of the
>>>>>> ModelPackageImpl:
>>>>>>
>>>>>> protected void createTeneoAnnotations() {
>>>>>> String source = "teneo.hibernate";
>>>>>> addAnnotation
>>>>>> (resourceEClass,
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@Table(name=\"Oresource\")"
>>>>>> }); ....
>>>>>> addAnnotation
>>>>>> (getActivityInstance_ProcessInstance(),
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>>>>> }); ....
>>>>>> addAnnotation
>>>>>> (getProcessInstance_Activities(),
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>>>>> mappedBy=processInstance)"
>>>>>> }); ....
>>>>>> addAnnotation
>>>>>> (getProcess_Activities(),
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>>>>> }); ....
>>>>>> }
>>>>>> protected void createTeneo_1Annotations()
>>>>>> String source = "teneo.jpa";
>>>>>> addAnnotation
>>>>>> (getResource_ScheduledActivities(),
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>>> cascade=NONE,mappedBy=assignedResources)"
>>>>>> }); ....
>>>>>> addAnnotation
>>>>>> (getActivityInstance_AssignedResources(),
>>>>>> source,
>>>>>> new String[]
>>>>>> {
>>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>>> cascade=NONE)"
>>>>>> });
>>>>>> ....
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thomas a écrit :
>>>>>>> Hi Martin,
>>>>>>>
>>>>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>>>>> Yes, it is the many-to-one that is not fetch eager or fetch
>>>>>>> within the jpql request.
>>>>>>> My request is to get a resource, with its ActivityInstance which
>>>>>>> should contain a ProcessInstance
>>>>>>> I hope I am clear now ;)
>>>>>>>
>>>>>>> How can I have the hbm ? The model is generated
>>>>>>> I can give you a part of the ModelPackageImpl
>>>>>>> public void initializePackageContents() {
>>>>>>> ...
>>>>>>> // Initialize classes and features; add operations and
>>>>>>> parameters
>>>>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>>>> ...
>>>>>>> initEReference(getResource_ScheduledActivities(),
>>>>>>> this.getActivityInstance(),
>>>>>>> this.getActivityInstance_AssignedResources(),
>>>>>>> "scheduledActivities", null, 0, -1, Resource.class,
>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>> IS_ORDERED);
>>>>>>> ...
>>>>>>> initEClass(activityInstanceEClass,
>>>>>>> ActivityInstance.class, "ActivityInstance", !IS_ABSTRACT,
>>>>>>> !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>>>> ...
>>>>>>> initEReference(getActivityInstance_AssignedResources(),
>>>>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>> IS_ORDERED);
>>>>>>> ...
>>>>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>> IS_ORDERED);
>>>>>>> ...
>>>>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>>>> ...
>>>>>>> initEReference(getProcessInstance_Activities(),
>>>>>>> this.getActivityInstance(),
>>>>>>> this.getActivityInstance_ProcessInstance(), "activities", null,
>>>>>>> 0, -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
>>>>>>> IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>>>> ...
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> My request is:
>>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>>>>> r.id=:id
>>>>>>>
>>>>>>> If I ask to hibernate to print the Sql request, it is pretty
>>>>>>> good, with processInstance data but it is as the mapping doesn't
>>>>>>> work ???
>>>>>>>
>>>>>>> Before, I have done this request:
>>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>>> r.scheduledActivities a where r.id=:id
>>>>>>> As the Fetch is Eager into the description, and then, the sql
>>>>>>> request print by hibernate doesn't contain any ProcessInstance
>>>>>>> data ...
>>>>>>>
>>>>>>> It is as the container/containment relationship is not understood
>>>>>>> into teneo ...
>>>>>>>
>>>>>>> This is what I try to tell you the first time. Am I more clear now ?
>>>>>>>
>>>>>>> Thank you to have answer so quickly
>>>>>>> Regards
>>>>>>>
>>>>>>> Thomas
>>>>>>>
>>>>>>> Martin Taal a écrit :
>>>>>>>> Hi Thomas,
>>>>>>>> I am not sure that I fully understand what you mean:
>>>>>>>> - do you expect the ProcessInstance to be loaded in the top of
>>>>>>>> the resource?, or
>>>>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>>>>
>>>>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Thomas wrote:
>>>>>>>>> Hi All,
>>>>>>>>>
>>>>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>>>>> relation with e Fetch Eager
>>>>>>>>>
>>>>>>>>> Here is my relation:
>>>>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>>>>
>>>>>>>>> scheduledActivities:
>>>>>>>>> *container,containment to false
>>>>>>>>> *EOpposite fill
>>>>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>>>>
>>>>>>>>> processInstance:
>>>>>>>>> *container true, containment false
>>>>>>>>> *EOpposite fill
>>>>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>>>>
>>>>>>>>> When I request a resource with its scheduled activities and
>>>>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>>>>> activities, but without it processInstance (on debug, I see
>>>>>>>>> that their are no eContainer, and the getProcessInstance give
>>>>>>>>> the eContainer).
>>>>>>>>> The Sql request is good when I explicitly ask processInstance,
>>>>>>>>> but not good if I didn't explicitly ask it.
>>>>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>>>>> Have you ever seen something like that ?
>>>>>>>>> Am I wrong ?
>>>>>>>>> Thanks to help me
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>> Thomas
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>
>>>>>
>>
>>
[Teneo] Re: Fetch Eager and container [message #426150 is a reply to message #426148] Wed, 17 December 2008 10:53 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Thomas,
Sorry, I missed your post last week, if I don't answer in 1 day just repeat the post. Also the
[Teneo] tag (which I added) in the subject helps.

It is true that eopposite and the jpa annotations both cover the same bidirectional mapping.
However, this does not necessarily mean that there are issues. For example here (below) is the
mapping of the books-author in the library example (see below).

Can you make a test project which reproduces the issue you have with your model? Then I can take a
look at it.

<list name="books" lazy="true" cascade="merge,persist,save-update,lock,refresh">
<key update="true">
<column name="`book_author_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`writer_books_idx`"/>
<one-to-many entity-name="Book"/>
</list>

<many-to-one name="author" entity-name="Writer" lazy="false"
cascade="merge,persist,save-update,lock,refresh" foreign-key="book_author" insert="false"
update="false" not-null="false">
<column not-null="false" unique="false" name="`book_author_e_id`"/>
</many-to-one>

gr. Martin

Thomas wrote:
> I took a lot of time to find a good way for my project.
> the EOpposite give us a lot of problems one a relation
> manyToOne/OneToMany declared on jpa.
> as in jpa it is already declared, I forgive the emf EOpposite property
> and it works fine.
> on a ManyToMany relation, it seems work fine.
>
> Thomas a écrit :
>> Yes, you have seen well, processInstance is the opposite of
>> activities, and it is really strange this double naming.
>> Is the EOpposite compatible with the mappedBy of JPA ? Who should
>> manage the bidirectionality of the relation ?
>>
>> Here, the order is important.
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> Do you mean the processInstance feature/column/property?
>>> is processInstance the opposite of activities? Because the strange
>>> thing is that they map to different columns: ACTVTYN_PRCSSNS_D and
>>> ACTVTYN_PRCSSNS.
>>>
>>> Note that something which plays a role here is that activities is an
>>> indexed collection. Teneo maps it so that the column to store this
>>> association is controlled from the activities side. See this chapter
>>> in the hibernate manual why this is done like this:
>>> Bidirectional associations with indexed collections
>>>
>>> If the order is not important then you can make the activities
>>> collection non-indexed by doing
>>> @OneToMany(indexed=false)
>>>
>>> Then the mapping will be different. Also adding a @JoinTable
>>> annotation makes the mapping different (although then you will have a
>>> join table).
>>>
>>> But again I find it strange that the columns on both sides of the
>>> associations are different.
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> I think, it is the EOpposite that doesn't work with Teneo/Hibernate
>>>> I have strengthened my constraints, and so, I have found that my
>>>> insert are not complete. The column of relation is not inserted into
>>>> database.
>>>> It is not declared into the all column of the sql request AS
>>>> hibernate add weel the constraint on database creation !!!!!!!!
>>>> It is amazing. Is it a well known bug or miss use ???
>>>>
>>>> Thomas a écrit :
>>>>> Ok, here it goes.
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>>>> DTD 3.0//EN"
>>>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>>>>
>>>>> <hibernate-mapping auto-import="false">
>>>>> <class entity-name="Resource" abstract="false" lazy="false"
>>>>> discriminator-value="Resource" table="`ORESOURCE`">
>>>>> <meta attribute="eclassName">Resource</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>>> <id name="id" type="long" unsaved-value="0">
>>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`DTYPE`" type="string"/>
>>>>> <property name="name" lazy="false" insert="true"
>>>>> update="true" not-null="true" unique="false" type="java.lang.String">
>>>>> <column not-null="true" unique="false" name="`NAME`"/>
>>>>> </property>
>>>>> ...
>>>>> <list name="scheduledActivities" lazy="true"
>>>>> table="`RSRC_SCHDLDCTVITIS`">
>>>>> <key update="true">
>>>>> <column name="`RESOURCE_ID`" not-null="true"
>>>>> unique="false"/>
>>>>> </key>
>>>>> <list-index column="`RSRC_SCHDLDCTVT_DX`"/>
>>>>> <many-to-many entity-name="ActivityInstance"
>>>>> unique="false" foreign-key="RSRC_SCHDLDCTVITIS">
>>>>> <column name="`ACTIVITYINSTNCE_ID`" not-null="true"
>>>>> unique="false"/>
>>>>> </many-to-many>
>>>>> </list>
>>>>> ...
>>>>> </class>
>>>>> ...
>>>>> <class entity-name="ActivityInstance" abstract="false"
>>>>> lazy="false" discriminator-value="ActivityInstance"
>>>>> table="`ACTIVITYINSTANCE`">
>>>>> <meta attribute="eclassName">ActivityInstance</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>>> <id name="id" type="long" unsaved-value="0">
>>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`DTYPE`" type="string"/>
>>>>> ...
>>>>> <list name="assignedResources" lazy="true"
>>>>> table="`ACTVTYNS_SSGNDRSR`">
>>>>> <key update="true">
>>>>> <column name="`ACTIVITYINSTANCID`" not-null="true"
>>>>> unique="false"/>
>>>>> </key>
>>>>> <list-index column="`ACTVTYN_SSGNDRS_DX`"/>
>>>>> <many-to-many entity-name="Resource" unique="false"
>>>>> foreign-key="ACTVTYNS_SSGNDRSR">
>>>>> <column name="`RESOURCE_ID`" not-null="true"
>>>>> unique="false"/>
>>>>> </many-to-many>
>>>>> </list>
>>>>> ...
>>>>> <many-to-one name="processInstance"
>>>>> entity-name="ProcessInstance" cascade="refresh"
>>>>> foreign-key="ACTVTYNS_PRCSSNST" lazy="false" insert="false"
>>>>> update="false" not-null="false">
>>>>> <column not-null="false" unique="false"
>>>>> name="`ACTVTYN_PRCSSNS_D`"/>
>>>>> </many-to-one>
>>>>> ...
>>>>> </class>
>>>>> ...
>>>>> <class entity-name="ProcessInstance" abstract="false"
>>>>> lazy="false" discriminator-value="ProcessInstance"
>>>>> table="`PROCESSINSTANCE`">
>>>>> <meta attribute="eclassName">ProcessInstance</meta>
>>>>> <meta
>>>>> attribute="epackage">http:///com.oslo.dreams.model</meta>
>>>>> <id name="id" type="long" unsaved-value="0">
>>>>> <column not-null="true" unique="false" name="`ID`"/>
>>>>> <generator class="native"/>
>>>>> </id>
>>>>> <discriminator column="`DTYPE`" type="string"/>
>>>>> ...
>>>>> <list name="activities" lazy="false"
>>>>> cascade="all,delete-orphan">
>>>>> <key update="true">
>>>>> <column name="`ACTVTYNS_PRCSSNST`" not-null="false"
>>>>> unique="false"/>
>>>>> </key>
>>>>> <list-index column="`PRCSSNSTN_CTVTS_DX`"/>
>>>>> <one-to-many entity-name="ActivityInstance"/>
>>>>> </list>
>>>>> ...
>>>>> </class>
>>>>>
>>>>> Have you got enough information about the hibernate configuration .
>>>>>
>>>>> Martin Taal a écrit :
>>>>>> Hi Thomas,
>>>>>> The annotation looks good, so I would need to see the hbm to see
>>>>>> if something goes wrong there. You can get the mapping from the
>>>>>> datastore doing getMappingXML after the datastore has initialized.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Thomas wrote:
>>>>>>> By the way, I have forgotten to tell you that we are using the
>>>>>>> EntityManager and to give you some other parts of the
>>>>>>> ModelPackageImpl:
>>>>>>>
>>>>>>> protected void createTeneoAnnotations() {
>>>>>>> String source = "teneo.hibernate";
>>>>>>> addAnnotation
>>>>>>> (resourceEClass,
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@Table(name=\"Oresource\")"
>>>>>>> }); ....
>>>>>>> addAnnotation
>>>>>>> (getActivityInstance_ProcessInstance(),
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@ManyToOne(fetch=EAGER, cascade=REFRESH)"
>>>>>>> }); ....
>>>>>>> addAnnotation
>>>>>>> (getProcessInstance_Activities(),
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL,
>>>>>>> mappedBy=processInstance)"
>>>>>>> }); ....
>>>>>>> addAnnotation
>>>>>>> (getProcess_Activities(),
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@OneToMany(fetch=EAGER, cascade=ALL)"
>>>>>>> }); ....
>>>>>>> }
>>>>>>> protected void createTeneo_1Annotations()
>>>>>>> String source = "teneo.jpa";
>>>>>>> addAnnotation
>>>>>>> (getResource_ScheduledActivities(),
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>>>> cascade=NONE,mappedBy=assignedResources)"
>>>>>>> }); ....
>>>>>>> addAnnotation
>>>>>>> (getActivityInstance_AssignedResources(),
>>>>>>> source,
>>>>>>> new String[]
>>>>>>> {
>>>>>>> "appinfo", "@ManyToMany(indexed=true, fetch=LAZY,
>>>>>>> cascade=NONE)"
>>>>>>> });
>>>>>>> ....
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thomas a écrit :
>>>>>>>> Hi Martin,
>>>>>>>>
>>>>>>>> No, the ProcessInstance has to be into the ActivityInstance.
>>>>>>>> Yes, it is the many-to-one that is not fetch eager or fetch
>>>>>>>> within the jpql request.
>>>>>>>> My request is to get a resource, with its ActivityInstance which
>>>>>>>> should contain a ProcessInstance
>>>>>>>> I hope I am clear now ;)
>>>>>>>>
>>>>>>>> How can I have the hbm ? The model is generated
>>>>>>>> I can give you a part of the ModelPackageImpl
>>>>>>>> public void initializePackageContents() {
>>>>>>>> ...
>>>>>>>> // Initialize classes and features; add operations and
>>>>>>>> parameters
>>>>>>>> initEClass(resourceEClass, Resource.class, "Resource",
>>>>>>>> !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>>>>> ...
>>>>>>>> initEReference(getResource_ScheduledActivities(),
>>>>>>>> this.getActivityInstance(),
>>>>>>>> this.getActivityInstance_AssignedResources(),
>>>>>>>> "scheduledActivities", null, 0, -1, Resource.class,
>>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>>> IS_ORDERED);
>>>>>>>> ...
>>>>>>>> initEClass(activityInstanceEClass,
>>>>>>>> ActivityInstance.class, "ActivityInstance", !IS_ABSTRACT,
>>>>>>>> !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
>>>>>>>> ...
>>>>>>>> initEReference(getActivityInstance_AssignedResources(),
>>>>>>>> this.getResource(), this.getResource_ScheduledActivities(),
>>>>>>>> "assignedResources", null, 0, -1, ActivityInstance.class,
>>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>>> IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>>> IS_ORDERED);
>>>>>>>> ...
>>>>>>>> initEReference(getActivityInstance_ProcessInstance(),
>>>>>>>> this.getProcessInstance(), this.getProcessInstance_Activities(),
>>>>>>>> "processInstance", null, 0, 1, ActivityInstance.class,
>>>>>>>> !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
>>>>>>>> !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED,
>>>>>>>> IS_ORDERED);
>>>>>>>> ...
>>>>>>>> initEClass(processInstanceEClass, ProcessInstance.class,
>>>>>>>> "ProcessInstance", !IS_ABSTRACT, !IS_INTERFACE,
>>>>>>>> IS_GENERATED_INSTANCE_CLASS);
>>>>>>>> ...
>>>>>>>> initEReference(getProcessInstance_Activities(),
>>>>>>>> this.getActivityInstance(),
>>>>>>>> this.getActivityInstance_ProcessInstance(), "activities", null,
>>>>>>>> 0, -1, ProcessInstance.class, !IS_TRANSIENT, !IS_VOLATILE,
>>>>>>>> IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
>>>>>>>> !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
>>>>>>>> ...
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> My request is:
>>>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>>>> r.scheduledActivities a LEFT JOIN FETCH a.ProcessInstance where
>>>>>>>> r.id=:id
>>>>>>>>
>>>>>>>> If I ask to hibernate to print the Sql request, it is pretty
>>>>>>>> good, with processInstance data but it is as the mapping doesn't
>>>>>>>> work ???
>>>>>>>>
>>>>>>>> Before, I have done this request:
>>>>>>>> SELECT DISTINCT r FROM Resource r LEFT JOIN FETCH
>>>>>>>> r.scheduledActivities a where r.id=:id
>>>>>>>> As the Fetch is Eager into the description, and then, the sql
>>>>>>>> request print by hibernate doesn't contain any ProcessInstance
>>>>>>>> data ...
>>>>>>>>
>>>>>>>> It is as the container/containment relationship is not
>>>>>>>> understood into teneo ...
>>>>>>>>
>>>>>>>> This is what I try to tell you the first time. Am I more clear
>>>>>>>> now ?
>>>>>>>>
>>>>>>>> Thank you to have answer so quickly
>>>>>>>> Regards
>>>>>>>>
>>>>>>>> Thomas
>>>>>>>>
>>>>>>>> Martin Taal a écrit :
>>>>>>>>> Hi Thomas,
>>>>>>>>> I am not sure that I fully understand what you mean:
>>>>>>>>> - do you expect the ProcessInstance to be loaded in the top of
>>>>>>>>> the resource?, or
>>>>>>>>> - is the processInstance many-to-one not eagerly fetched?
>>>>>>>>>
>>>>>>>>> Can you post the snippet of the hbm which relates to this?
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Thomas wrote:
>>>>>>>>>> Hi All,
>>>>>>>>>>
>>>>>>>>>> I have a problem with EMF/Teneo and container/containment on
>>>>>>>>>> relation with e Fetch Eager
>>>>>>>>>>
>>>>>>>>>> Here is my relation:
>>>>>>>>>> Resource --(scheduledActivities 0..n)->ActivitiyInstance
>>>>>>>>>> --(processInstance 0..1)-> ProcessInstance
>>>>>>>>>>
>>>>>>>>>> scheduledActivities:
>>>>>>>>>> *container,containment to false
>>>>>>>>>> *EOpposite fill
>>>>>>>>>> *teneo: @ManyToMany(indexed=true, fetch=LAZY,
>>>>>>>>>> cascade=NONE,mappedBy=AssignedResources)
>>>>>>>>>>
>>>>>>>>>> processInstance:
>>>>>>>>>> *container true, containment false
>>>>>>>>>> *EOpposite fill
>>>>>>>>>> *teneo: @ManyToOne(fetch=EAGER, cascade=REFRESH)
>>>>>>>>>>
>>>>>>>>>> When I request a resource with its scheduled activities and
>>>>>>>>>> processInstances, the result is a Resource, with its scheduled
>>>>>>>>>> activities, but without it processInstance (on debug, I see
>>>>>>>>>> that their are no eContainer, and the getProcessInstance give
>>>>>>>>>> the eContainer).
>>>>>>>>>> The Sql request is good when I explicitly ask processInstance,
>>>>>>>>>> but not good if I didn't explicitly ask it.
>>>>>>>>>> It is as Fetch EAGER doesn't work on container...
>>>>>>>>>> Have you ever seen something like that ?
>>>>>>>>>> Am I wrong ?
>>>>>>>>>> Thanks to help me
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> Thomas
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>
>>>>>>
>>>
>>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] Possible inconsistency using IdBags
Next Topic:.ecore file export as xmi file
Goto Forum:
  


Current Time: Fri Apr 19 01:28:44 GMT 2024

Powered by FUDForum. Page generated in 0.04035 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top