The code snippets below show some examples, for the full code check the Tutorial.java file in the examples project. The example show that you need to use model names in the HQL queries and not the java implementation names (this is also why Teneo supports Dynamic EMF out-of-the-box). In the next step these are queries again.Īs a next step the data is queried using HQL. The above code created and persisted a Library with a Book and a Writer. Not necessary ifĪs you can see, Teneo is not used explicitly at runtime, it is only standard EMF and Hibernate. save (library ) // Create a writer and book. setName ( "My Library" ) // Make it persistent. beginTransaction ( ) // Create a library. Open a new Session and start transaction. Teneo has many configuration options, these are set as follows: hibernateProperties.load(in) // // 2) or populated manually: // tProperty(Environment.DRIVER, "") // tProperty(Environment.USER, "root") // tProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/library") // tProperty(Environment.PASS, "root") // tProperty(Environment.DIALECT, "5InnoDBDialect") Properties hibernateProperties = new Properties ( ) // // 1) From a ".properties" file or stream. // Alternatively, you can set the properties programmatically: // // For more information see // section 3.1 of the Hibernate manual. By default the properties are obtained from the file // "hibernate.properties" at the classpath root. To configure Hibernate, supply properties describing the JDBC driver, // URL, username/password and SQL dialect. The initialization starts by setting both Hibernate as well as Teneo properties in a properties map: The initialization part calls Teneo directly, in the remaining runtime steps only EMF and Hibernate are directly used. The tutorial java class executes several steps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |