. . "2017-06-13T05:36:13Z" . . . "---+Virtuoso JDBC Driver Hibernate Support\n\n%TOC%\n\n---++What\n\nHibernate is a powerful, open source, high performance object/relational persistence and query service. Hibernate lets you develop persistent classes following the object-oriented idiom - including association, inheritance, polymorphism, composition, and collections. Hibernate allows you to express queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API.\n\n---++Why\n\nHibernate employs very aggressive, and very intelligent first and second level caching strategy, providing a high performance and scalable development framework for Java. Greater cross portability and productivity can also be achieve using hibernate as the same techniques can be employed across multiple databases.\n\n---++How\n\nHibernate uses JDBC for accessing databases and may require a given database has a custom SQL dialect file that informs Hibernate what SQL dialects are to be use for performing certain operations against the target database. Although not strictly required, it should be used to ensure Hibernate Query Language (HQL) statements are correctly converted into the proper SQL dialect for the underlying database. Virtuoso includes a new jar file called virt_dialect.jar containing the SQL dialect mappings required between hibernate and Virtuoso and is used in conjunction to the Virtuoso JDBC Drivers (virtjdbc3.jar or virtjdbc4.jar).\n\n---++Setup and Testing\n\nThree [[http://s3.amazonaws.com/opldownload/uda/virtuoso/6.1/hibernate/Hibernate_Examples.zip][sample programs]] are provided to test Virtuoso hibernate support. Extract the contents of the zip file to a location of choice.\n\n---+++Requirements\n\n * [[https://www.hibernate.org/][Hibernate]] 3.3 or higher\n * JDK 5.0 or higher on any operating system\n * Ant 1.6\n * [[http://s3.amazonaws.com/opldownload/uda/virtuoso/6.2/hibernate/virt_dialect.jar][Virtuoso SQL Dialect jar file]] (virt_dialect.jar)\n * [[http://s3.amazonaws.com/opldownload/uda/virtuoso/6.2/jdbc/virtjdbc4.jar][Virtuoso JDBC Driver jar file]] (virtjdbc4.jar)\n\n---+++Building and running the example\n\nThe following Ant targets are available:\n\n clean Clean the build directory\n compile Build example\n run Build and run example\n\n\n---+++Hibernate connection string\n\nEdit the file hibernate.cfg.xml in the \"bin\" and \"src\" directories of the hibernate application directory with the correct connection attributes for the Virtuoso Server instance:\n\n\n$ more hibernate.cfg.xml \n\n\n\n\n\n \n\n \n virtuoso.jdbc4.Driver\n jdbc:virtuoso://localhost:1111/\n dba\n dba\n\n \n 1\n\n \n virtuoso.hibernate.VirtuosoDialect\n\n \n thread\n\n \n org.hibernate.cache.NoCacheProvider\n\n \n true\n\n \n create\n\n \n\n \n\n\n\n\nThe key attributes to set are --\n\n * connection.driver_class - Virtuoso JDBC Driver class name, typically virtuoso.jdbc4.Driver\n * connection.url - Virtuoso JDBC Driver connect string for target Virtuoso server instance, of the form jdbc:virtuoso://hostname:portno\n * connection.username - Virtuoso Server username\n * connection.password - Virtuoso Server password\n\n---+++Example 1\n\nThis sample performs a simple insert and retrieval of data against the Virtuoso database.\n\n 1 Open your command shell and change to the \"ex1\" directory\n 1 Place the following required files in the ./lib directory:\n\nantlr-2.7.6.jar\ncommons-collections-3.1.jar\ncommons-logging-1.0.4.jar\ndom4j-1.6.1.jar\nhibernate3.jar\njavassist-3.4.GA.jar\njta-1.1.jar\nlib.lst\nlog4j-1.2.15.jar\nslf4j-api-1.5.10.jar\nslf4j-api-1.5.2.jar\nslf4j-jcl-1.5.10.jar\nvirtjdbc4.jar\nvirt_dialect.jar\n\n 1 Run the example with \"ant run\", and read the log output on the console.\n%BR%%BR%Note: Hibernate logging levels can be varied by changing the settings in the src/hibernate.cfg.xml and src/log4j.properties files.\n\n$ ant run\nBuildfile: build.xml\n\nclean:\n [delete] Deleting directory /Users/hughwilliams/hibernate/ex1/bin\n [mkdir] Created dir: /Users/hughwilliams/hibernate/ex1/bin\n\ncopy-resources:\n [copy] Copying 3 files to /Users/hughwilliams/hibernate/ex1/bin\n [copy] Copied 2 empty directories to 1 empty directory under /Users/hughwilliams/hibernate/ex1/bin\n\ncompile:\n [javac] Compiling 3 source files to /Users/hughwilliams/hibernate/ex1/bin\n\nrun:\n [java] Hibernate: insert into Event (EVENT_DATE, title) values (?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: insert into Event (EVENT_DATE, title) values (?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: select event0_.EVENT_ID as EVENT1_0_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from Event event0_\n [java] Event: My Event1 Time: 2010-03-14 03:27:51.0\n [java] Event: My Event2 Time: 2010-03-14 03:27:53.0\n\nBUILD SUCCESSFUL\nTotal time: 3 seconds\n\n\n---+++Example 2\n\nHello World with Java Persistence\n\n 1 Open your command shell and change to the \"ex2\" directory\n 1 Place the following required files in the ./lib directory:\n\nantlr-2.7.6.jar\nasm-attrs.jar\nasm.jar\nc3p0-0.9.0.jar\ncglib-2.1.3.jar\ncommons-collections-2.1.1.jar\ncommons-logging-1.0.4.jar\ndom4j-1.6.1.jar\nejb3-persistence.jar\nfreemarker.jar\nhibernate-annotations.jar\nhibernate-commons-annotations.jar\nhibernate-entitymanager.jar\nhibernate-tools.jar\nhibernate3.jar\njavassist.jar\njboss-archive-browsing.jar\njta.jar\nlog4j-1.2.13.jar\nvirtjdbc4.jar\nvirt_dialect.jar\n\n 1 Use \"ant schemaexport\" to export a database schema automatically to the database. Ignore any errors about failing ALTER TABLE statements; these are thrown because there are no tables when you run this for the first time.\n\n$ ant schemaexport\nBuildfile: build.xml\n\ncompile:\n\ncopymetafiles:\n\nschemaexport:\n[hibernatetool] Executing Hibernate Tool with a JPA Configuration\n[hibernatetool] 1. task: hbm2ddl (Generates database schema)\n[hibernatetool] \n[hibernatetool] drop table MESSAGES;\n[hibernatetool] \n[hibernatetool] create table MESSAGES (\n[hibernatetool] MESSAGE_ID decimal(20,0) identity,\n[hibernatetool] MESSAGE_TEXT varchar(255) null,\n[hibernatetool] NEXT_MESSAGE_ID decimal(20,0) null,\n[hibernatetool] primary key (MESSAGE_ID)\n[hibernatetool] );\n[hibernatetool] \n[hibernatetool] alter table MESSAGES \n[hibernatetool] add \n[hibernatetool] foreign key (NEXT_MESSAGE_ID) \n[hibernatetool] references MESSAGES;\n\nBUILD SUCCESSFUL\nTotal time: 2 seconds\n\n 1 Check the DDL that was also exported to the file helloworld-ddl.sql\n\n$ more helloworld-ddl.sql \n\n drop table MESSAGES;\n\n create table MESSAGES (\n MESSAGE_ID decimal(20,0) identity,\n MESSAGE_TEXT varchar(255) null,\n NEXT_MESSAGE_ID decimal(20,0) null,\n primary key (MESSAGE_ID)\n );\n\n alter table MESSAGES \n add \n foreign key (NEXT_MESSAGE_ID) \n references MESSAGES;\n\n 1 Run the example with \"ant run\", and read the log output on the console.\n%BR%%BR%Note: Hibernate logging levels can be varied by changing the settings in the src/etc/log4j.properties and\nsrc/etc/META-INF/persistence.xml files.\n\n$ ant run\nBuildfile: build.xml\n\ncompile:\n\ncopymetafiles:\n\nrun:\n [java] 1 message(s) found:\n [java] Hello World with JPA\n\nBUILD SUCCESSFUL\nTotal time: 2 seconds\n\n 1 Call ant run again\n\n$ ant run\nBuildfile: build.xml\n\ncompile:\n\ncopymetafiles:\n\nrun:\n [java] 2 message(s) found:\n [java] Hello World with JPA\n [java] Hello World with JPA\n\nBUILD SUCCESSFUL\nTotal time: 2 seconds\n\n 1 If you call ant schemaexport again, all tables will be re-created\n\n\n---+++Example 3\n\nThis sample performs more complex insert and retrieval of data against the Virtuoso database.\n\n 1 Open your command shell and change to the \"ex3\" directory\n 1 The following required files need to be placed in the ./lib directory:\n\nantlr-2.7.6.jar\ncommons-collections-3.1.jar\ncommons-logging-1.0.4.jar\ndom4j-1.6.1.jar\nhibernate3.jar\njavassist-3.4.GA.jar\njta-1.1.jar\nlibs.lst\nlog4j-1.2.15.jar\nslf4j-api-1.5.10.jar\nslf4j-api-1.5.2.jar\nslf4j-jcl-1.5.10.jar\nvirtjdbc4.jar\nvirt_dialect.jar\n\n 1 Run the example with \"ant run\", and read the log output on the console.\n%BR%%BR%Note: Hibernate logging levels can be varied by changing the settings in the src/hibernate.cfg.xml and src/log4j.properties files.\n\n$ ant run\nBuildfile: build.xml\n\nclean:\n [delete] Deleting directory /Users/hughwilliams/hibernate/ex3/bin\n [mkdir] Created dir: /Users/hughwilliams/hibernate/ex3/bin\n\ncopy-resources:\n [copy] Copying 4 files to /Users/hughwilliams/hibernate/ex3/bin\n [copy] Copied 2 empty directories to 1 empty directory under /Users/hughwilliams/hibernate/ex3/bin\n\ncompile:\n [javac] Compiling 4 source files to /Users/hughwilliams/hibernate/ex3/bin\n [javac] Note: Some input files use unchecked or unsafe operations.\n [javac] Note: Recompile with -Xlint:unchecked for details.\n\nrun:\n [java] Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: insert into PERSON (age, firstname, lastname) values (?, ?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: select person0_.PERSON_ID as PERSON1_2_0_, event2_.EVENT_ID as EVENT1_0_1_, person0_.age as age2_0_, person0_.firstname as firstname2_0_, person0_.lastname as lastname2_0_, event2_.EVENT_DATE as EVENT2_0_1_, event2_.title as title0_1_, events1_.PERSON_ID as PERSON2_0__, events1_.EVENT_ID as EVENT1_0__ from PERSON person0_ left outer join PERSON_EVENT events1_ on person0_.PERSON_ID=events1_.PERSON_ID left outer join EVENTS event2_ on events1_.EVENT_ID=event2_.EVENT_ID where person0_.PERSON_ID=?\n [java] Hibernate: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?\n [java] Hibernate: select participan0_.EVENT_ID as EVENT1_1_, participan0_.PERSON_ID as PERSON2_1_, person1_.PERSON_ID as PERSON1_2_0_, person1_.age as age2_0_, person1_.firstname as firstname2_0_, person1_.lastname as lastname2_0_ from PERSON_EVENT participan0_ left outer join PERSON person1_ on participan0_.PERSON_ID=person1_.PERSON_ID where participan0_.EVENT_ID=?\n [java] Hibernate: insert into PERSON_EVENT (PERSON_ID, EVENT_ID) values (?, ?)\n [java] Hibernate: update PERSON set age=?, firstname=?, lastname=? where PERSON_ID=?\n [java] Added person 1 to event 2\n [java] Hibernate: insert into PERSON (age, firstname, lastname) values (?, ?, ?)\n [java] Hibernate: select identity_value()\n [java] Hibernate: select person0_.PERSON_ID as PERSON1_2_0_, person0_.age as age2_0_, person0_.firstname as firstname2_0_, person0_.lastname as lastname2_0_ from PERSON person0_ where person0_.PERSON_ID=?\n [java] Hibernate: select emailaddre0_.PERSON_ID as PERSON1_0_, emailaddre0_.EMAIL_ADDR as EMAIL2_0_ from PERSON_EMAIL_ADDR emailaddre0_ where emailaddre0_.PERSON_ID=?\n [java] Hibernate: insert into PERSON_EMAIL_ADDR (PERSON_ID, EMAIL_ADDR) values (?, ?)\n [java] Hibernate: select person0_.PERSON_ID as PERSON1_2_0_, person0_.age as age2_0_, person0_.firstname as firstname2_0_, person0_.lastname as lastname2_0_ from PERSON person0_ where person0_.PERSON_ID=?\n [java] Hibernate: select emailaddre0_.PERSON_ID as PERSON1_0_, emailaddre0_.EMAIL_ADDR as EMAIL2_0_ from PERSON_EMAIL_ADDR emailaddre0_ where emailaddre0_.PERSON_ID=?\n [java] Hibernate: insert into PERSON_EMAIL_ADDR (PERSON_ID, EMAIL_ADDR) values (?, ?)\n [java] Added two email addresses (value typed objects) to person entity : 1\n [java] Hibernate: select event0_.EVENT_ID as EVENT1_0_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from EVENTS event0_\n [java] Event: My Event Time: 2010-03-14 03:30:02.0\n [java] Event: My Event Time: 2010-03-14 03:30:06.0\n\nBUILD SUCCESSFUL\nTotal time: 5 seconds\n\n\n" . "2017-06-13T05:36:13Z" . "VirtJdbcHibernate" . . . . . . . . . . "VirtJdbcHibernate" . "2017-06-13T05:36:13.957977"^^ . . "2017-06-13T05:36:13.957977"^^ . . "VirtJdbcHibernate" . . "0cb164ce199cb5ef77231875f7166d1a" . .