Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EList/List setter and iBatis
EList/List setter and iBatis [message #416769] Mon, 18 February 2008 12:35 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
As I use iBatis for persisting my EMF model to the database, the model
needs also setters for list objects.
I simply add those to the model by hand after code generation, like
mentioned here:
http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html

There was also a consideration to add an option for this to the
generator model (back in 2004 mentioned here:
http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html)

I searched Bugzilla for an enhancement request, but didn't found
anything. Did I miss something? Is that option perhaps somewhere there?
Or was this idea dropped?

Kai
Re: EList/List setter and iBatis [message #416770 is a reply to message #416769] Mon, 18 February 2008 12:39 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Kai Schlamp wrote:
> As I use iBatis for persisting my EMF model to the database, the model
> needs also setters for list objects.
> I simply add those to the model by hand after code generation, like
> mentioned here:
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html
>
> There was also a consideration to add an option for this to the
> generator model (back in 2004 mentioned here:
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html)

Sorry, i meant this link:
http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7056.html


>
> I searched Bugzilla for an enhancement request, but didn't found
> anything. Did I miss something? Is that option perhaps somewhere there?
> Or was this idea dropped?
>
> Kai
Re: EList/List setter and iBatis [message #416771 is a reply to message #416770] Mon, 18 February 2008 12:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Kai,

I'm also using iBatis and add the method for setting the list my own. I
don't think that this can be done automatically for some reasons.

The most important one is that when setting the list directly from the
outside lazy loading doesn't work any more. You need some tricks to make
this work appropriately.

My model looks like this:

-------------8<-------------
protected EList<Session> sessions; // The EMF-generated object
private List<Session> orginalSession; // The object coming from iBatis
// when using lazy loading it is a
// proxy
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> */
> public List<Session> getSessions() {
> if (sessions == null) {
> sessions = new EObjectContainmentWithInverseEList<Session>(Session.class, this, ingeniumPackage.CLIENT__SESSIONS, ingeniumPackage.SESSION__PERSON);
>
> ChangeRecordManager.getManager().runWithoutChangeRecording(n ew Runnable() {
> public void run() {
> if (orginalSession != null) {
> sessions.addAll(orginalSession);
> }
> }
> });
> }
>
> return sessions;
> }

-------------8<-------------

If you don't care about change recording you don't need the
runWithoutChangeRecording. I my application I need this and have to
suspend all registered change recorders while the lazy-loading is
happening else my Editors and Views would report a wrong dirty-state.

Did you find another solution to this problem?

Tom

Kai Schlamp schrieb:
> Kai Schlamp wrote:
>> As I use iBatis for persisting my EMF model to the database, the model
>> needs also setters for list objects.
>> I simply add those to the model by hand after code generation, like
>> mentioned here:
>> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html
>>
>> There was also a consideration to add an option for this to the
>> generator model (back in 2004 mentioned here:
>> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html)
>
> Sorry, i meant this link:
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7056.html
>
>
>> I searched Bugzilla for an enhancement request, but didn't found
>> anything. Did I miss something? Is that option perhaps somewhere there?
>> Or was this idea dropped?
>>
>> Kai


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: EList/List setter and iBatis [message #416783 is a reply to message #416771] Tue, 19 February 2008 10:10 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Hello Tom,

I never thought about that lazy loading problem.
I just use a setter like this:
public void setXXX(List<XXX> xxx) {
ECollections.setEList(this.xxx, xxx);
}
and thought, that everything would work this way.
But I am still more in the planning phase and now think about, if
perhaps teneo/hibernate would be a better solution (as I am also not
dependent on a given database schema).

Kai

Tom Schindl wrote:
> Hi Kai,
>
> I'm also using iBatis and add the method for setting the list my own. I
> don't think that this can be done automatically for some reasons.
>
> The most important one is that when setting the list directly from the
> outside lazy loading doesn't work any more. You need some tricks to make
> this work appropriately.
>
> My model looks like this:
>
> -------------8<-------------
> protected EList<Session> sessions; // The EMF-generated object
> private List<Session> orginalSession; // The object coming from iBatis
> // when using lazy loading it is a
> // proxy
>> /**
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> */
>> public List<Session> getSessions() {
>> if (sessions == null) {
>> sessions = new
>> EObjectContainmentWithInverseEList<Session>(Session.class, this,
>> ingeniumPackage.CLIENT__SESSIONS, ingeniumPackage.SESSION__PERSON);
>>
>>
>> ChangeRecordManager.getManager().runWithoutChangeRecording(n ew
>> Runnable() {
>> public void run() {
>> if (orginalSession != null) {
>> sessions.addAll(orginalSession);
>> }
>> }
>> });
>> }
>>
>> return sessions;
>> }
>
> -------------8<-------------
>
> If you don't care about change recording you don't need the
> runWithoutChangeRecording. I my application I need this and have to
> suspend all registered change recorders while the lazy-loading is
> happening else my Editors and Views would report a wrong dirty-state.
>
> Did you find another solution to this problem?
>
> Tom
>
> Kai Schlamp schrieb:
>> Kai Schlamp wrote:
>>> As I use iBatis for persisting my EMF model to the database, the model
>>> needs also setters for list objects.
>>> I simply add those to the model by hand after code generation, like
>>> mentioned here:
>>> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html
>>>
>>> There was also a consideration to add an option for this to the
>>> generator model (back in 2004 mentioned here:
>>> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7053.html)
>>
>> Sorry, i meant this link:
>> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg0 7056.html
>>
>>
>>> I searched Bugzilla for an enhancement request, but didn't found
>>> anything. Did I miss something? Is that option perhaps somewhere there?
>>> Or was this idea dropped?
>>>
>>> Kai
>
>
Re: EList/List setter and iBatis [message #416785 is a reply to message #416783] Tue, 19 February 2008 10:28 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Kai Schlamp schrieb:
> Hello Tom,
>
> I never thought about that lazy loading problem.
> I just use a setter like this:
> public void setXXX(List<XXX> xxx) {
> ECollections.setEList(this.xxx, xxx);
> }

Well this violates lazy loading :-( because EMF queries the proxy
and this results in fetching the objects from your database (in fact
you'll fetch the whole object-graph at once).

I've never used Teneo and don't know how it prevents from these
situations but used iBatis with great success in a project lately. Still
i think I'll take a look on Teneo soon until then I'm satisfied with my
solution because everything is under my control (even the SQL-Statements
used to query the database) :-)

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Cross references between resources that have been sent over the wire
Next Topic:FileDialog Browse Workspace
Goto Forum:
  


Current Time: Sat Apr 27 01:50:08 GMT 2024

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

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

Back to the top