Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] QuickStart Tutorial fails to create tables(tables are not created for the ECore model in the tutorial)
[Teneo] QuickStart Tutorial fails to create tables [message #656804] Mon, 28 February 2011 16:55 Go to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
when this line is executed, from within QuickStart

session.save(lib);


The errors seem clear that the table was not created. But where does the table creation occur (or should occur)? I am not getting any other errors.

Thanks for your help / insight!

I get the following errors:

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [Library]


Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.library' doesn't exist
Re: [Teneo] QuickStart Tutorial fails to create tables [message #656814 is a reply to message #656804] Mon, 28 February 2011 17:27 Go to previous messageGo to next message
Joao S is currently offline Joao S
Messages: 51
Registered: January 2011
Member
I think you´re looking for this:

hbds.initialize();


I believe this is where tables should be created.

Are you sure your properties are correct?

When you look at your database are your tables there?

Joao

[Updated on: Mon, 28 February 2011 17:29]

Report message to a moderator

Re: [Teneo] QuickStart Tutorial fails to create tables [message #656818 is a reply to message #656814] Mon, 28 February 2011 17:37 Go to previous messageGo to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
No the table are not being created in the DB.

I did step into : hbds.initialize();

and step through the code. I could not determine where the tables are been (should be) created.

Where does the code step through the ecore model and make the call to create the corresponding tables?

Thanks

Robert
Re: [Teneo] QuickStart Tutorial fails to create tables [message #656819 is a reply to message #656814] Mon, 28 February 2011 17:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hi Robert,
Teneo will automatically set this Environment.HBM2DDL_AUTO to update if it was not set explicitly. Hibernate does not
stop if the database/table creation fails initially, it will continue until you actually try to insert data. Can you
check if you see errors earlier in the log when the datastore initializes?

gr. Martin

On 02/28/2011 06:27 PM, Joao wrote:
> I think you´re looking for this:
>
> hbds.initialize();
>
> I believe this is where tables should be created.
>
> Are you sure your properties are correct?
>
> Joao


--

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: [Teneo] QuickStart Tutorial fails to create tables [message #656831 is a reply to message #656818] Mon, 28 February 2011 18:01 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
You can check what happens here:
HbDataStore.setDefaultProperties

the Environment.HBM2DDL_AUTO should there be set to update
There you can also see if it is already set somehow.

gr. Martin

On 02/28/2011 06:37 PM, Robert Lario wrote:
> No the table are not being created in the DB.
>
> I did step into : hbds.initialize();
>
> and step through the code. I could not determine where the tables are been (should be) created.
> Where does the code step through the ecore model and make the call to create the corresponding tables?
>
> Thanks
>
> Robert


--

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: [Teneo] QuickStart Tutorial fails to create tables [message #656833 is a reply to message #656814] Mon, 28 February 2011 18:10 Go to previous messageGo to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
Where would I find the log files. I checked within my project, but could not find any log files.
Re: [Teneo] QuickStart Tutorial fails to create tables [message #656835 is a reply to message #656833] Mon, 28 February 2011 18:21 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Here are some docs:
http://wiki.eclipse.org/Teneo/Hibernate/FAQ#Troubleshooting_ the_Mapping_and_Runtime_layer.2FHibernate

On 02/28/2011 07:10 PM, Robert Lario wrote:
> Where would I find the log files. I checked within my project, but could not find any log files.


--

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: [Teneo] QuickStart Tutorial fails to create tables [message #656861 is a reply to message #656835] Mon, 28 February 2011 19:35 Go to previous messageGo to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
Adding the logging information helped identify where the issues is. Tnx

Does Teneo work with MySQL? Is there a special setting or configuration I need for Teneo to work with MySQL?

It appears that it does not like type InnoDB. Where is what I found in the logs


0 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: create table `book` (e_id bigint not null auto_increment, dtype varchar(255) not null, e_version integer not null, `title` varchar(255) not null, `pages` integer, `category` varchar(255), author bigint, `library_books_e_id` bigint, `library_books_idx` integer, econtainer_class varchar(255), e_container varchar(255), e_container_feature_name varchar(255), primary key (e_id)) type=InnoDB
32 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
Re: [Teneo] QuickStart Tutorial fails to create tables [message #656870 is a reply to message #656861] Mon, 28 February 2011 20:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Yes sure, Hibernate/Teneo works fine with Mysql, what hibernate dialect are you using?

gr. Martin

On 02/28/2011 08:35 PM, Robert Lario wrote:
> Adding the logging information helped identify where the issues is. Tnx
>
> Does Teneo work with MySQL? Is there a special setting or configuration I need for Teneo to work with MySQL?
>
> It appears that it does not like type InnoDB. Where is what I found in the logs
>
>
> 0 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: create table `book` (e_id bigint not null
> auto_increment, dtype varchar(255) not null, e_version integer not null, `title` varchar(255) not null, `pages` integer,
> `category` varchar(255), author bigint, `library_books_e_id` bigint, `library_books_idx` integer, econtainer_class
> varchar(255), e_container varchar(255), e_container_feature_name varchar(255), primary key (e_id)) type=InnoDB
> 32 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1


--

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: [Teneo] QuickStart Tutorial fails to create tables [message #656871 is a reply to message #656835] Mon, 28 February 2011 20:26 Go to previous messageGo to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
it appears that "type=InnoDB" is the offending statement. MySQL syntex "ENGINE=InnoDB".

I took (statement being used by TENEO to create the table):
create table `library` (e_id bigint not null auto_increment, dtype varchar(255) not null, e_version integer not null, `name` varchar(255) not null, primary key (e_id)) type=InnoDB

and changed it to ENGINE (not TYPE) and executed in the MySQL Workbench :
create table `library` (e_id bigint not null auto_increment, dtype varchar(255) not null, e_version integer not null, `name` varchar(255) not null, primary key (e_id)) ENGINE=InnoDB

This works fine.

Is there a means to change the statement created by TENEO to use "ENGINE" and not "TYPE"?
Re: [Teneo] QuickStart Tutorial fails to create tables [message #656879 is a reply to message #656871] Mon, 28 February 2011 21:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hmm, I wonder why this happens with you and not with me ;-). Teneo does not generate these create statements, it is
native Hibernate which does this (which I guess should work with mysql).

Can you show how you set the properties? What dialect do you use?

gr. Martin

On 02/28/2011 09:26 PM, Robert Lario wrote:
> it appears that "type=InnoDB" is the offending statement. MySQL syntex "ENGINE=InnoDB".
>
> I took (statement being used by TENEO to create the table):
> create table `library` (e_id bigint not null auto_increment, dtype varchar(255) not null, e_version integer not null,
> `name` varchar(255) not null, primary key (e_id)) type=InnoDB
>
> and changed it to ENGINE (not TYPE) and executed in the MySQL Workbench :
> create table `library` (e_id bigint not null auto_increment, dtype varchar(255) not null, e_version integer not null,
> `name` varchar(255) not null, primary key (e_id)) ENGINE=InnoDB
>
> This works fine.
>
> Is there a means to change the statement created by TENEO to use "ENGINE" and not "TYPE"?
>


--

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: [Teneo] QuickStart Tutorial fails to create tables [message #656888 is a reply to message #656871] Mon, 28 February 2011 22:10 Go to previous messageGo to next message
Robert Lario is currently offline Robert Lario
Messages: 8
Registered: February 2011
Junior Member
I was using the wrong dialect.


changed it to : props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLDialect.class.getName());

Works great! Thanks for your help!
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1006698 is a reply to message #656888] Fri, 01 February 2013 13:36 Go to previous messageGo to next message
M B is currently offline M B
Messages: 4
Registered: February 2013
Junior Member
I create from example here rcp-vision_com: "Eclipse EMF: an out-of-the-box CRUD for a database".
But I use H2 database.
Database properties are next:

		// create the data store
		HbDataStore hbds = (HbDataStore) HbHelper.INSTANCE.createRegisterDataStore("MyDB");
		
		//Set Database properties
		Properties props = new Properties();
		props.setProperty(Environment.DRIVER, "org.h2.Driver");
		props.setProperty(Environment.URL, "jdbc:h2:~/test1");
		props.setProperty(Environment.USER, "sa");
		props.setProperty(Environment.PASS, "");
		props.setProperty(Environment.DIALECT,  org.hibernate.dialect.H2Dialect.class.getName());
		props.setProperty(Environment.SHOW_SQL, "true");
		props.setProperty(Environment.HBM2DDL_AUTO, "update");
		// props.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
                hbds.setProperties(props);
		
                //Register EMF package in this datastore
		hbds.setEPackages(new EPackage[] { LibraryPackage.eINSTANCE });
		
		// initialize, also creates the database tables
		try {
			hbds.initialize();
		} finally {
			// print the generated mapping
			System.err.println(hbds.getMappingXML());
		}


Have an error on initialize.

Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.hibernate.HbHelper createRegisterDataStore
INFO: Creating emf data store and registering it under name: MyDB
Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.hibernate.HbHelper createRegisterDataStore
INFO: Returning created emf data store, initialize this newly created data store!
Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.classloader.ClassLoaderResolver setClassLoaderStrategy
INFO: Class loader strategy set to: org.eclipse.emf.teneo.classloader.ContextClassLoaderStrategy
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See ... for more info.
...
!ENTRY org.eclipse.osgi 4 0 2013-02-01 14:16:20.924
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: org/hibernate/cache/HashtableCacheProvider
	at org.eclipse.emf.teneo.hibernate.HbDataStore.setDefaultProperties(HbDataStore.java:403)
	at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.setPropertiesInConfiguration(HbSessionDataStore.java:137)
	at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.initialize(HbSessionDataStore.java:79)
	at library.presentation.LibraryEditorAdvisor.initialize(LibraryEditorAdvisor.java:589)
...


Could you give me an advise?
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1006747 is a reply to message #1006698] Fri, 01 February 2013 16:33 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hi MB,
Did you install the hibernate plugin?
http://wiki.eclipse.org/Teneo/Hibernate/Download_and_Install#Plugins_and_dependencies.2C_update_site_locations

and if so did you add the hibernate plugin of the plugin running your test code.

gr. Martin


On 02/01/2013 03:18 PM, M B wrote:
> I create from example here rcp-vision_com: "Eclipse EMF: an out-of-the-box CRUD for a database".
> But I use H2 database.
> Database properties are next:
>
> // create the data store
> HbDataStore hbds = (HbDataStore) HbHelper.INSTANCE.createRegisterDataStore("MyDB");
>
> //Set Database properties
> Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "org.h2.Driver");
> props.setProperty(Environment.URL, "jdbc:h2:~/test1");
> props.setProperty(Environment.USER, "sa");
> props.setProperty(Environment.PASS, "");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
> props.setProperty(Environment.SHOW_SQL, "true");
> props.setProperty(Environment.HBM2DDL_AUTO, "update");
> // props.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
> hbds.setProperties(props);
>
> //Register EMF package in this datastore
> hbds.setEPackages(new EPackage[] { LibraryPackage.eINSTANCE });
>
> // initialize, also creates the database tables
> try {
> hbds.initialize();
> } finally {
> // print the generated mapping
> System.err.println(hbds.getMappingXML());
> }
>
> Have an error on initialize.
>
> Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.hibernate.HbHelper createRegisterDataStore
> INFO: Creating emf data store and registering it under name: MyDB
> Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.hibernate.HbHelper createRegisterDataStore
> INFO: Returning created emf data store, initialize this newly created data store!
> Feb 01, 2013 2:16:20 PM org.eclipse.emf.teneo.classloader.ClassLoaderResolver setClassLoaderStrategy
> INFO: Class loader strategy set to: org.eclipse.emf.teneo.classloader.ContextClassLoaderStrategy
> log4j:WARN No appenders could be found for logger (org.jboss.logging).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See ... for more info.
> ...
> !ENTRY org.eclipse.osgi 4 0 2013-02-01 14:16:20.924
> !MESSAGE Application error
> !STACK 1
> java.lang.NoClassDefFoundError: org/hibernate/cache/HashtableCacheProvider
> at org.eclipse.emf.teneo.hibernate.HbDataStore.setDefaultProperties(HbDataStore.java:403)
> at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.setPropertiesInConfiguration(HbSessionDataStore.java:137)
> at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.initialize(HbSessionDataStore.java:79)
> at library.presentation.LibraryEditorAdvisor.initialize(LibraryEditorAdvisor.java:589)
> ...
>
> Could you give me an advise?
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1006857 is a reply to message #1006747] Sat, 02 February 2013 23:57 Go to previous messageGo to next message
M B is currently offline M B
Messages: 4
Registered: February 2013
Junior Member
Thank you for the answer!

Yes, I have installed all needed plugins (org.eclipse.emf.teneo.hibernate,
org.hibernate, org.h2) and have added it in dependencies of *.editor/plugin.xml.
Plugin for H2 I have created as Plugin from existing JAR and have added too.
However I have this error on initialize().

What can I check else?
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1006975 is a reply to message #1006857] Sun, 03 February 2013 13:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hi MB,
Not sure, I don't recognize the line number from Teneo in the latest version. Which Teneo and which Hibernate version
are you using?

For the update sites of the latest versions:
http://wiki.eclipse.org/Teneo/Hibernate/Download_and_Install#Plugins_and_dependencies.2C_update_site_locations


gr. Martin

On 02/03/2013 12:57 AM, M B wrote:
> Thank you for the answer!
>
> Yes, I have installed all needed plugins (org.eclipse.emf.teneo.hibernate, org.hibernate, org.h2) and have added it in
> dependencies of *.editor/plugin.xml. Plugin for H2 I have created as Plugin from existing JAR and have added too.
> However I have this error on initialize().
>
> What can I check else?


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1006976 is a reply to message #1006857] Sun, 03 February 2013 13:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hi MB,
Not sure, I don't recognize the line number from Teneo in the latest version. Which Teneo and which Hibernate version
are you using?

For the update sites of the latest versions:
http://wiki.eclipse.org/Teneo/Hibernate/Download_and_Install#Plugins_and_dependencies.2C_update_site_locations

gr. Martin


On 02/03/2013 12:57 AM, M B wrote:
> Thank you for the answer!
>
> Yes, I have installed all needed plugins (org.eclipse.emf.teneo.hibernate, org.hibernate, org.h2) and have added it in
> dependencies of *.editor/plugin.xml. Plugin for H2 I have created as Plugin from existing JAR and have added too.
> However I have this error on initialize().
>
> What can I check else?


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] QuickStart Tutorial fails to create tables [message #1007082 is a reply to message #1006976] Mon, 04 February 2013 11:31 Go to previous message
M B is currently offline M B
Messages: 4
Registered: February 2013
Junior Member
The problem was in wrong version (now I have other error).

Thank you Martin!
Previous Topic:EcoreUtil.copyAll and EMap
Next Topic:Client-/Server Architecture with Server-Side EMF Model
Goto Forum:
  


Current Time: Mon Sep 22 14:26:26 GMT 2014

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

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