Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Can't add data
[Teneo] Can't add data [message #73414] Thu, 01 March 2007 19:48 Go to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
(oops -- forgot to put [Teneo] on subject)

I'm trying to add some emf objects like in the tutorial step 3. I can
create the root object, but then when I try to add something to a list in
that object, it doesn't work. The Server object below returns an
EList<Plugin> object. When I add a Plugin object to the EList, it seems to
work, but then when I read it back again, nothing is there. I put in a
flush, and reopened the session to see what would happen, and even
re-queried, but no use. I must be doing something incorrectly. Any ideas?

public Server addPlugin(String serverID,Plugin plugin) throws
ModelServiceException
{
Session session=sessionFactory.openSession();
Query query=session.createQuery("FROM Server where id='"+serverID+"'");
Server server=(Server)query.list().get(0);
getLogger().info("initial plugin count:"+server.getPlugins().size());
session.beginTransaction();
server.getPlugins().add(plugin);
session.getTransaction().commit();
session.flush();
session.close();
session=sessionFactory.openSession();
query=session.createQuery("FROM Server where id='"+serverID+"'");
server=(Server)query.list().get(0);
getLogger().info("new plugin count:"+server.getPlugins().size());
return server;

}

Output from the log statements shows count of zero.
Re: [Teneo] Can't add data [message #73438 is a reply to message #73414] Thu, 01 March 2007 19:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Can you try to do session.saveOrUpdate(server) just before the commit?

gr. Martin

Paul Gardiner wrote:
> (oops -- forgot to put [Teneo] on subject)
>
> I'm trying to add some emf objects like in the tutorial step 3. I can
> create the root object, but then when I try to add something to a list in
> that object, it doesn't work. The Server object below returns an
> EList<Plugin> object. When I add a Plugin object to the EList, it seems to
> work, but then when I read it back again, nothing is there. I put in a
> flush, and reopened the session to see what would happen, and even
> re-queried, but no use. I must be doing something incorrectly. Any ideas?
>
> public Server addPlugin(String serverID,Plugin plugin) throws
> ModelServiceException
> {
> Session session=sessionFactory.openSession();
> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
> Server server=(Server)query.list().get(0);
> getLogger().info("initial plugin count:"+server.getPlugins().size());
> session.beginTransaction();
> server.getPlugins().add(plugin);
> session.getTransaction().commit();
> session.flush();
> session.close();
> session=sessionFactory.openSession();
> query=session.createQuery("FROM Server where id='"+serverID+"'");
> server=(Server)query.list().get(0);
> getLogger().info("new plugin count:"+server.getPlugins().size());
> return server;
>
> }
>
> Output from the log statements shows count of zero.
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: [Teneo] Can't add data [message #73457 is a reply to message #73438] Thu, 01 March 2007 20:08 Go to previous messageGo to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
I had tried session.update(server) before, but I tried save and saveOrUpdate
as well, and I still get the same result.

Just to make sure I'm initializing correctly, here's the body of my
initialization method:

store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
store.initialize();
sessionFactory = store.getSessionFactory();

In particular, is the setEPackages correct?

"Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
> Hi Paul,
> Can you try to do session.saveOrUpdate(server) just before the commit?
>
> gr. Martin
>
> Paul Gardiner wrote:
>> (oops -- forgot to put [Teneo] on subject)
>>
>> I'm trying to add some emf objects like in the tutorial step 3. I can
>> create the root object, but then when I try to add something to a list in
>> that object, it doesn't work. The Server object below returns an
>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>> to
>> work, but then when I read it back again, nothing is there. I put in a
>> flush, and reopened the session to see what would happen, and even
>> re-queried, but no use. I must be doing something incorrectly. Any
>> ideas?
>>
>> public Server addPlugin(String serverID,Plugin plugin) throws
>> ModelServiceException
>> {
>> Session session=sessionFactory.openSession();
>> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
>> Server server=(Server)query.list().get(0);
>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>> session.beginTransaction();
>> server.getPlugins().add(plugin);
>> session.getTransaction().commit();
>> session.flush();
>> session.close();
>> session=sessionFactory.openSession();
>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>> server=(Server)query.list().get(0);
>> getLogger().info("new plugin count:"+server.getPlugins().size());
>> return server;
>>
>> }
>>
>> Output from the log statements shows count of zero.
>>
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> 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: [Teneo] Can't add data [message #73474 is a reply to message #73457] Thu, 01 March 2007 20:16 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes it looks fine. Can you print the mapping xml (store.getMappingXML()) and then post the mapping
for the server eclass?
Can you try to make other changes to the server object to see if they are persisted (or not)?

gr. Martin

Paul Gardiner wrote:
> I had tried session.update(server) before, but I tried save and saveOrUpdate
> as well, and I still get the same result.
>
> Just to make sure I'm initializing correctly, here's the body of my
> initialization method:
>
> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
> store.initialize();
> sessionFactory = store.getSessionFactory();
>
> In particular, is the setEPackages correct?
>
> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>> Hi Paul,
>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> (oops -- forgot to put [Teneo] on subject)
>>>
>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>> create the root object, but then when I try to add something to a list in
>>> that object, it doesn't work. The Server object below returns an
>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>> to
>>> work, but then when I read it back again, nothing is there. I put in a
>>> flush, and reopened the session to see what would happen, and even
>>> re-queried, but no use. I must be doing something incorrectly. Any
>>> ideas?
>>>
>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>> ModelServiceException
>>> {
>>> Session session=sessionFactory.openSession();
>>> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> Server server=(Server)query.list().get(0);
>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>> session.beginTransaction();
>>> server.getPlugins().add(plugin);
>>> session.getTransaction().commit();
>>> session.flush();
>>> session.close();
>>> session=sessionFactory.openSession();
>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> server=(Server)query.list().get(0);
>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>> return server;
>>>
>>> }
>>>
>>> Output from the log statements shows count of zero.
>>>
>>>
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> 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
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: [Teneo] Can't add data [message #73873 is a reply to message #73457] Wed, 07 March 2007 02:29 Go to previous messageGo to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Call session.save(plugin) before calling
server.getPlugins().add(plugin);

I have noticed that EObjects instantiated by the model factory don't have
the right EList implementations until teneo becomes aware of them (thru the
session).
In particular, the first call to EList.add does not seem to work but
subsequent ones do.

If you left out session.save(plugin) but called the following line twice,
you would get a reference to the plugin.
server.getPlugins().add(plugin);

Disclaimer: maybe I am completely wrong about this but moving my
session.save call up just fixed a problem that I was having adding
references too.
-mike


"Paul Gardiner" <pgardiner@syntellect.com> wrote in message
news:es7bso$upu$1@utils.eclipse.org...
>I had tried session.update(server) before, but I tried save and
>saveOrUpdate as well, and I still get the same result.
>
> Just to make sure I'm initializing correctly, here's the body of my
> initialization method:
>
> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
> store.initialize();
> sessionFactory = store.getSessionFactory();
>
> In particular, is the setEPackages correct?
>
> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>> Hi Paul,
>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> (oops -- forgot to put [Teneo] on subject)
>>>
>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>> create the root object, but then when I try to add something to a list
>>> in
>>> that object, it doesn't work. The Server object below returns an
>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>> to
>>> work, but then when I read it back again, nothing is there. I put in a
>>> flush, and reopened the session to see what would happen, and even
>>> re-queried, but no use. I must be doing something incorrectly. Any
>>> ideas?
>>>
>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>> ModelServiceException
>>> {
>>> Session session=sessionFactory.openSession();
>>> Query query=session.createQuery("FROM Server where
>>> id='"+serverID+"'");
>>> Server server=(Server)query.list().get(0);
>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>> session.beginTransaction();
>>> server.getPlugins().add(plugin);
>>> session.getTransaction().commit();
>>> session.flush();
>>> session.close();
>>> session=sessionFactory.openSession();
>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> server=(Server)query.list().get(0);
>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>> return server;
>>>
>>> }
>>>
>>> Output from the log statements shows count of zero.
>>>
>>>
>>>
>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> 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: [Teneo] Can't add data [message #73891 is a reply to message #73873] Wed, 07 March 2007 02:50 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Mike,
Just for my understanding, what do you mean with this part of your post?
> If you left out session.save(plugin) but called the following line twice,
> you would get a reference to the plugin.
> server.getPlugins().add(plugin);

gr. Martin


Michael Kanaley wrote:
> Call session.save(plugin) before calling
> server.getPlugins().add(plugin);
>
> I have noticed that EObjects instantiated by the model factory don't have
> the right EList implementations until teneo becomes aware of them (thru the
> session).
> In particular, the first call to EList.add does not seem to work but
> subsequent ones do.
>
> If you left out session.save(plugin) but called the following line twice,
> you would get a reference to the plugin.
> server.getPlugins().add(plugin);
>
> Disclaimer: maybe I am completely wrong about this but moving my
> session.save call up just fixed a problem that I was having adding
> references too.
> -mike
>
>
> "Paul Gardiner" <pgardiner@syntellect.com> wrote in message
> news:es7bso$upu$1@utils.eclipse.org...
>> I had tried session.update(server) before, but I tried save and
>> saveOrUpdate as well, and I still get the same result.
>>
>> Just to make sure I'm initializing correctly, here's the body of my
>> initialization method:
>>
>> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
>> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
>> store.initialize();
>> sessionFactory = store.getSessionFactory();
>>
>> In particular, is the setEPackages correct?
>>
>> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>>> Hi Paul,
>>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>>
>>> gr. Martin
>>>
>>> Paul Gardiner wrote:
>>>> (oops -- forgot to put [Teneo] on subject)
>>>>
>>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>>> create the root object, but then when I try to add something to a list
>>>> in
>>>> that object, it doesn't work. The Server object below returns an
>>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>>> to
>>>> work, but then when I read it back again, nothing is there. I put in a
>>>> flush, and reopened the session to see what would happen, and even
>>>> re-queried, but no use. I must be doing something incorrectly. Any
>>>> ideas?
>>>>
>>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>>> ModelServiceException
>>>> {
>>>> Session session=sessionFactory.openSession();
>>>> Query query=session.createQuery("FROM Server where
>>>> id='"+serverID+"'");
>>>> Server server=(Server)query.list().get(0);
>>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>>> session.beginTransaction();
>>>> server.getPlugins().add(plugin);
>>>> session.getTransaction().commit();
>>>> session.flush();
>>>> session.close();
>>>> session=sessionFactory.openSession();
>>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>>> server=(Server)query.list().get(0);
>>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>>> return server;
>>>>
>>>> }
>>>>
>>>> Output from the log statements shows count of zero.
>>>>
>>>>
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> 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
>>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: [Teneo] Can't add data [message #603052 is a reply to message #73414] Thu, 01 March 2007 19:59 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Paul,
Can you try to do session.saveOrUpdate(server) just before the commit?

gr. Martin

Paul Gardiner wrote:
> (oops -- forgot to put [Teneo] on subject)
>
> I'm trying to add some emf objects like in the tutorial step 3. I can
> create the root object, but then when I try to add something to a list in
> that object, it doesn't work. The Server object below returns an
> EList<Plugin> object. When I add a Plugin object to the EList, it seems to
> work, but then when I read it back again, nothing is there. I put in a
> flush, and reopened the session to see what would happen, and even
> re-queried, but no use. I must be doing something incorrectly. Any ideas?
>
> public Server addPlugin(String serverID,Plugin plugin) throws
> ModelServiceException
> {
> Session session=sessionFactory.openSession();
> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
> Server server=(Server)query.list().get(0);
> getLogger().info("initial plugin count:"+server.getPlugins().size());
> session.beginTransaction();
> server.getPlugins().add(plugin);
> session.getTransaction().commit();
> session.flush();
> session.close();
> session=sessionFactory.openSession();
> query=session.createQuery("FROM Server where id='"+serverID+"'");
> server=(Server)query.list().get(0);
> getLogger().info("new plugin count:"+server.getPlugins().size());
> return server;
>
> }
>
> Output from the log statements shows count of zero.
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: [Teneo] Can't add data [message #603056 is a reply to message #73438] Thu, 01 March 2007 20:08 Go to previous message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
I had tried session.update(server) before, but I tried save and saveOrUpdate
as well, and I still get the same result.

Just to make sure I'm initializing correctly, here's the body of my
initialization method:

store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
store.initialize();
sessionFactory = store.getSessionFactory();

In particular, is the setEPackages correct?

"Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
> Hi Paul,
> Can you try to do session.saveOrUpdate(server) just before the commit?
>
> gr. Martin
>
> Paul Gardiner wrote:
>> (oops -- forgot to put [Teneo] on subject)
>>
>> I'm trying to add some emf objects like in the tutorial step 3. I can
>> create the root object, but then when I try to add something to a list in
>> that object, it doesn't work. The Server object below returns an
>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>> to
>> work, but then when I read it back again, nothing is there. I put in a
>> flush, and reopened the session to see what would happen, and even
>> re-queried, but no use. I must be doing something incorrectly. Any
>> ideas?
>>
>> public Server addPlugin(String serverID,Plugin plugin) throws
>> ModelServiceException
>> {
>> Session session=sessionFactory.openSession();
>> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
>> Server server=(Server)query.list().get(0);
>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>> session.beginTransaction();
>> server.getPlugins().add(plugin);
>> session.getTransaction().commit();
>> session.flush();
>> session.close();
>> session=sessionFactory.openSession();
>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>> server=(Server)query.list().get(0);
>> getLogger().info("new plugin count:"+server.getPlugins().size());
>> return server;
>>
>> }
>>
>> Output from the log statements shows count of zero.
>>
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> 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: [Teneo] Can't add data [message #603058 is a reply to message #73457] Thu, 01 March 2007 20:16 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes it looks fine. Can you print the mapping xml (store.getMappingXML()) and then post the mapping
for the server eclass?
Can you try to make other changes to the server object to see if they are persisted (or not)?

gr. Martin

Paul Gardiner wrote:
> I had tried session.update(server) before, but I tried save and saveOrUpdate
> as well, and I still get the same result.
>
> Just to make sure I'm initializing correctly, here's the body of my
> initialization method:
>
> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
> store.initialize();
> sessionFactory = store.getSessionFactory();
>
> In particular, is the setEPackages correct?
>
> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>> Hi Paul,
>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> (oops -- forgot to put [Teneo] on subject)
>>>
>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>> create the root object, but then when I try to add something to a list in
>>> that object, it doesn't work. The Server object below returns an
>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>> to
>>> work, but then when I read it back again, nothing is there. I put in a
>>> flush, and reopened the session to see what would happen, and even
>>> re-queried, but no use. I must be doing something incorrectly. Any
>>> ideas?
>>>
>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>> ModelServiceException
>>> {
>>> Session session=sessionFactory.openSession();
>>> Query query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> Server server=(Server)query.list().get(0);
>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>> session.beginTransaction();
>>> server.getPlugins().add(plugin);
>>> session.getTransaction().commit();
>>> session.flush();
>>> session.close();
>>> session=sessionFactory.openSession();
>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> server=(Server)query.list().get(0);
>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>> return server;
>>>
>>> }
>>>
>>> Output from the log statements shows count of zero.
>>>
>>>
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> 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
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: [Teneo] Can't add data [message #603185 is a reply to message #73457] Wed, 07 March 2007 02:29 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Call session.save(plugin) before calling
server.getPlugins().add(plugin);

I have noticed that EObjects instantiated by the model factory don't have
the right EList implementations until teneo becomes aware of them (thru the
session).
In particular, the first call to EList.add does not seem to work but
subsequent ones do.

If you left out session.save(plugin) but called the following line twice,
you would get a reference to the plugin.
server.getPlugins().add(plugin);

Disclaimer: maybe I am completely wrong about this but moving my
session.save call up just fixed a problem that I was having adding
references too.
-mike


"Paul Gardiner" <pgardiner@syntellect.com> wrote in message
news:es7bso$upu$1@utils.eclipse.org...
>I had tried session.update(server) before, but I tried save and
>saveOrUpdate as well, and I still get the same result.
>
> Just to make sure I'm initializing correctly, here's the body of my
> initialization method:
>
> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
> store.initialize();
> sessionFactory = store.getSessionFactory();
>
> In particular, is the setEPackages correct?
>
> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>> Hi Paul,
>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>
>> gr. Martin
>>
>> Paul Gardiner wrote:
>>> (oops -- forgot to put [Teneo] on subject)
>>>
>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>> create the root object, but then when I try to add something to a list
>>> in
>>> that object, it doesn't work. The Server object below returns an
>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>> to
>>> work, but then when I read it back again, nothing is there. I put in a
>>> flush, and reopened the session to see what would happen, and even
>>> re-queried, but no use. I must be doing something incorrectly. Any
>>> ideas?
>>>
>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>> ModelServiceException
>>> {
>>> Session session=sessionFactory.openSession();
>>> Query query=session.createQuery("FROM Server where
>>> id='"+serverID+"'");
>>> Server server=(Server)query.list().get(0);
>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>> session.beginTransaction();
>>> server.getPlugins().add(plugin);
>>> session.getTransaction().commit();
>>> session.flush();
>>> session.close();
>>> session=sessionFactory.openSession();
>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>> server=(Server)query.list().get(0);
>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>> return server;
>>>
>>> }
>>>
>>> Output from the log statements shows count of zero.
>>>
>>>
>>>
>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> 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: [Teneo] Can't add data [message #603189 is a reply to message #73873] Wed, 07 March 2007 02:50 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Mike,
Just for my understanding, what do you mean with this part of your post?
> If you left out session.save(plugin) but called the following line twice,
> you would get a reference to the plugin.
> server.getPlugins().add(plugin);

gr. Martin


Michael Kanaley wrote:
> Call session.save(plugin) before calling
> server.getPlugins().add(plugin);
>
> I have noticed that EObjects instantiated by the model factory don't have
> the right EList implementations until teneo becomes aware of them (thru the
> session).
> In particular, the first call to EList.add does not seem to work but
> subsequent ones do.
>
> If you left out session.save(plugin) but called the following line twice,
> you would get a reference to the plugin.
> server.getPlugins().add(plugin);
>
> Disclaimer: maybe I am completely wrong about this but moving my
> session.save call up just fixed a problem that I was having adding
> references too.
> -mike
>
>
> "Paul Gardiner" <pgardiner@syntellect.com> wrote in message
> news:es7bso$upu$1@utils.eclipse.org...
>> I had tried session.update(server) before, but I tried save and
>> saveOrUpdate as well, and I still get the same result.
>>
>> Just to make sure I'm initializing correctly, here's the body of my
>> initialization method:
>>
>> store = HbHelper.INSTANCE.createRegisterDataStore(DATA_STORE_NAME);
>> store.setEPackages(new EPackage[] { ModelPackage.eINSTANCE });
>> store.initialize();
>> sessionFactory = store.getSessionFactory();
>>
>> In particular, is the setEPackages correct?
>>
>> "Martin Taal" wrote in message news:es7bb2$tlq$1@utils.eclipse.org...
>>> Hi Paul,
>>> Can you try to do session.saveOrUpdate(server) just before the commit?
>>>
>>> gr. Martin
>>>
>>> Paul Gardiner wrote:
>>>> (oops -- forgot to put [Teneo] on subject)
>>>>
>>>> I'm trying to add some emf objects like in the tutorial step 3. I can
>>>> create the root object, but then when I try to add something to a list
>>>> in
>>>> that object, it doesn't work. The Server object below returns an
>>>> EList<Plugin> object. When I add a Plugin object to the EList, it seems
>>>> to
>>>> work, but then when I read it back again, nothing is there. I put in a
>>>> flush, and reopened the session to see what would happen, and even
>>>> re-queried, but no use. I must be doing something incorrectly. Any
>>>> ideas?
>>>>
>>>> public Server addPlugin(String serverID,Plugin plugin) throws
>>>> ModelServiceException
>>>> {
>>>> Session session=sessionFactory.openSession();
>>>> Query query=session.createQuery("FROM Server where
>>>> id='"+serverID+"'");
>>>> Server server=(Server)query.list().get(0);
>>>> getLogger().info("initial plugin count:"+server.getPlugins().size());
>>>> session.beginTransaction();
>>>> server.getPlugins().add(plugin);
>>>> session.getTransaction().commit();
>>>> session.flush();
>>>> session.close();
>>>> session=sessionFactory.openSession();
>>>> query=session.createQuery("FROM Server where id='"+serverID+"'");
>>>> server=(Server)query.list().get(0);
>>>> getLogger().info("new plugin count:"+server.getPlugins().size());
>>>> return server;
>>>>
>>>> }
>>>>
>>>> Output from the log statements shows count of zero.
>>>>
>>>>
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> 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
>>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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:EEnum to Epackage relationship lost
Next Topic:How to set the hibernate "where" clause in teneo?
Goto Forum:
  


Current Time: Tue Apr 16 10:10:14 GMT 2024

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

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

Back to the top