Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Insert / Delete instead of Update
[Teneo] Insert / Delete instead of Update [message #620278] Tue, 02 September 2008 02:09
Andrew H is currently offline Andrew HFriend
Messages: 117
Registered: July 2009
Senior Member
I'm running the library example and looking in the hypersonic logs and
noticed some odd behaviour.

It appears that no updates are ever issued but instead rows are deleted
and inserted. Also a lot more SQL is executed than would be required.
Obviously you need to allow for some inefficiencies with a persistence
framework but it seemed excessive to me.

Running the first section of the example as follows

----
// Open a new Session and start transaction.
final Session session = sessionFactory.openSession();
session.beginTransaction();

// Create a library.
Library library = LibraryFactory.eINSTANCE.createLibrary();
library.setName("My Library");
// Make it persistent.
session.save(library);

// Create a writer...
Writer writer = LibraryFactory.eINSTANCE.createWriter();
writer.setName("JRR Tolkien");

// ...and one of his books.
Book book = LibraryFactory.eINSTANCE.createBook();
book.setAuthor(writer);
book.setPages(305);
book.setTitle("The Hobbit");
book.setCategory(BookCategory.SCIENCE_FICTION);

// Add the Writer and Book to the Library. They are made
// persistent automatically because the Library is already
// persistent.
library.getWriters().add(writer);
library.getBooks().add(book);

// Commit the changes to the database.
session.getTransaction().commit();
// Close the session. Not necessary if
session.close();

----

Results in

---
INSERT IGNORE INTO "library" VALUES(1,'Library',0,'My Library')
INSERT IGNORE INTO "writer" VALUES(1,'Writer',0,'JRR
Tolkien',NULL,NULL,'Library','1',-2)
INSERT IGNORE INTO "book" VALUES(1,'Book',0,'The
Hobbit',305,'ScienceFiction',1,NULL,NULL,'Library','1',-3)
DELETE FROM "writer" WHERE E_ID=1
INSERT IGNORE INTO "writer" VALUES(1,'Writer',0,'JRR
Tolkien',1,0,'Library','1',-2)
DELETE FROM "book" WHERE E_ID=1
INSERT IGNORE INTO "book" VALUES(1,'Book',0,'The
Hobbit',305,'ScienceFiction',1,1,0,'Library','1',-3)
INSERT IGNORE INTO "writer_books" VALUES(1,1,0)
---

Where as all that was really needed was

---
INSERT IGNORE INTO "library" VALUES(1,'Library',0,'My Library')
INSERT IGNORE INTO "writer" VALUES(1,'Writer',0,'JRR
Tolkien',1,0,'Library','1',-2)
INSERT IGNORE INTO "book" VALUES(1,'Book',0,'The
Hobbit',305,'ScienceFiction',1,1,0,'Library','1',-3)
INSERT IGNORE INTO "writer_books" VALUES(1,1,0)
---

Is this a Teneo or hibernate issue?
Its been a while since I did hibernate but don't remember that?
Previous Topic:Merge EMF (UML) Models
Next Topic:[EMF Compare] Wrong targets in movements?
Goto Forum:
  


Current Time: Fri Sep 20 17:56:15 GMT 2024

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

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

Back to the top