This HTML5 document contains 34 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
dctermshttp://purl.org/dc/terms/
atomhttp://atomowl.org/ontologies/atomrdf#
n10http://download3.openlinksw.com/uda/virtuoso/6.2/hibernate/virt_dialect.
foafhttp://xmlns.com/foaf/0.1/
n16http://vos.openlinksw.com/dataspace/services/wiki/
oplhttp://www.openlinksw.com/schema/attribution#
n4http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
dchttp://purl.org/dc/elements/1.1/
n15http://download3.openlinksw.com/uda/virtuoso/6.1/hibernate/Hibernate_Examples.
n5http://vos.openlinksw.com/dataspace/dav#
rdfshttp://www.w3.org/2000/01/rdf-schema#
n22https://www.hibernate.org/
n17http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n7http://vos.openlinksw.com/dataspace/person/dav#
n19http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/VirtJdbcHibernate/sioc.
n6http://vos.openlinksw.com/dataspace/owiki/wiki/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n12http://download3.openlinksw.com/uda/virtuoso/jdbc/virtjdbc4.
n2http://vos.openlinksw.com/dataspace/owiki#
xsdhhttp://www.w3.org/2001/XMLSchema#
n20http://vos.openlinksw.com/dataspace/person/owiki#
siochttp://rdfs.org/sioc/ns#
Subject Item
n7:this
foaf:made
n4:VirtJdbcHibernate
Subject Item
n5:this
sioc:creator_of
n4:VirtJdbcHibernate
Subject Item
n16:item
n17:services_of
n4:VirtJdbcHibernate
Subject Item
n2:this
sioc:creator_of
n4:VirtJdbcHibernate
Subject Item
n6:VOS
sioc:container_of
n4:VirtJdbcHibernate
atom:entry
n4:VirtJdbcHibernate
atom:contains
n4:VirtJdbcHibernate
Subject Item
n4:VirtJdbcHibernate
rdf:type
sioct:Comment atom:Entry
dcterms:created
2018-04-13T12:06:54.373851
dcterms:modified
2018-05-16T10:00:45.626220
rdfs:label
VirtJdbcHibernate
foaf:maker
n7:this n20:this
dc:title
VirtJdbcHibernate
opl:isDescribedUsing
n19:rdf
sioc:has_creator
n5:this n2:this
sioc:content
---+ Virtuoso JDBC Driver Hibernate Support %TOC% ---++What Hibernate 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. ---++Why Hibernate 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. ---++How Hibernate uses JDBC for accessing databases and may require a given database has a custom <code>SQL dialect</code> 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 <code>virt_dialect.jar</code> containing the SQL dialect mappings required between hibernate and Virtuoso and is used in conjunction to the Virtuoso JDBC Drivers (<code>virtjdbc3.jar</code> or <code>virtjdbc4.jar</code>). ---++Setup and Testing Three [[http://download3.openlinksw.com/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. ---+++Requirements * [[https://www.hibernate.org/][Hibernate]] 3.3 or higher * JDK 5.0 or higher on any operating system * Ant 1.6 * [[http://download3.openlinksw.com/uda/virtuoso/6.2/hibernate/virt_dialect.jar][Virtuoso SQL Dialect jar file]] (<code>virt_dialect.jar</code>) * [[http://download3.openlinksw.com/uda/virtuoso/jdbc/virtjdbc4.jar][Virtuoso JDBC Driver jar file]] (<code>virtjdbc4.jar</code>) ---+++Building and running the example The following Ant targets are available: <verbatim> clean Clean the build directory compile Build example run Build and run example </verbatim> ---+++Hibernate connection string Edit the file <code>hibernate.cfg.xml</code> in the "<code>bin</code>" and "<code>src</code>" directories of the hibernate application directory with the correct connection attributes for the Virtuoso Server instance: <verbatim> $ more hibernate.cfg.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">virtuoso.jdbc4.Driver</property> <property name="connection.url">jdbc:virtuoso://localhost:1111/</property> <property name="connection.username">dba</property> <property name="connection.password">dba</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">virtuoso.hibernate.VirtuosoDialect</property> <!-- Enable Hibernate's current session context --> <property name="current_session_context_class">thread</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <mapping resource="events/Event.hbm.xml"/> </session-factory> </hibernate-configuration> </verbatim> The key attributes to set are -- * <b><code>connection.driver_class</code></b> - Virtuoso JDBC Driver class name, typically <code>virtuoso.jdbc4.Driver</code> * <b><code>connection.url</code></b> - Virtuoso JDBC Driver connect string for target Virtuoso server instance, of the form <code>jdbc:virtuoso://hostname:portno</code> * <b><code>connection.username</code></b> - Virtuoso Server username * <b><code>connection.password</code></b> - Virtuoso Server password ---+++Example 1 This sample performs a simple insert and retrieval of data against the Virtuoso database. 1 Open your command shell and change to the "<code>ex1</code>" directory 1 Place the following required files in the <code>./lib</code> directory: <verbatim> antlr-2.7.6.jar commons-collections-3.1.jar commons-logging-1.0.4.jar dom4j-1.6.1.jar hibernate3.jar javassist-3.4.GA.jar jta-1.1.jar lib.lst log4j-1.2.15.jar slf4j-api-1.5.10.jar slf4j-api-1.5.2.jar slf4j-jcl-1.5.10.jar virtjdbc4.jar virt_dialect.jar </verbatim> 1 Run the example with "<code>ant run</code>", and read the log output on the console. %BR%%BR%<i><b>Note:</b> Hibernate logging levels can be varied by changing the settings in the <code>src/hibernate.cfg.xml</code> and <code>src/log4j.properties</code> files.</i> <verbatim> $ ant run Buildfile: build.xml clean: [delete] Deleting directory /Users/hughwilliams/hibernate/ex1/bin [mkdir] Created dir: /Users/hughwilliams/hibernate/ex1/bin copy-resources: [copy] Copying 3 files to /Users/hughwilliams/hibernate/ex1/bin [copy] Copied 2 empty directories to 1 empty directory under /Users/hughwilliams/hibernate/ex1/bin compile: [javac] Compiling 3 source files to /Users/hughwilliams/hibernate/ex1/bin run: [java] Hibernate: insert into Event (EVENT_DATE, title) values (?, ?) [java] Hibernate: select identity_value() [java] Hibernate: insert into Event (EVENT_DATE, title) values (?, ?) [java] Hibernate: select identity_value() [java] Hibernate: select event0_.EVENT_ID as EVENT1_0_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from Event event0_ [java] Event: My Event1 Time: 2010-03-14 03:27:51.0 [java] Event: My Event2 Time: 2010-03-14 03:27:53.0 BUILD SUCCESSFUL Total time: 3 seconds </verbatim> ---+++Example 2 Hello World with Java Persistence 1 Open your command shell and change to the "<code>ex2</code>" directory 1 Place the following required files in the <code>./lib</code> directory: <verbatim> antlr-2.7.6.jar asm-attrs.jar asm.jar c3p0-0.9.0.jar cglib-2.1.3.jar commons-collections-2.1.1.jar commons-logging-1.0.4.jar dom4j-1.6.1.jar ejb3-persistence.jar freemarker.jar hibernate-annotations.jar hibernate-commons-annotations.jar hibernate-entitymanager.jar hibernate-tools.jar hibernate3.jar javassist.jar jboss-archive-browsing.jar jta.jar log4j-1.2.13.jar virtjdbc4.jar virt_dialect.jar </verbatim> 1 Use "<code>ant schemaexport</code>" to export a database schema automatically to the database. Ignore any errors about failing <code>ALTER TABLE</code> statements; these are thrown because there are no tables when you run this for the first time. <verbatim> $ ant schemaexport Buildfile: build.xml compile: copymetafiles: schemaexport: [hibernatetool] Executing Hibernate Tool with a JPA Configuration [hibernatetool] 1. task: hbm2ddl (Generates database schema) [hibernatetool] [hibernatetool] drop table MESSAGES; [hibernatetool] [hibernatetool] create table MESSAGES ( [hibernatetool] MESSAGE_ID decimal(20,0) identity, [hibernatetool] MESSAGE_TEXT varchar(255) null, [hibernatetool] NEXT_MESSAGE_ID decimal(20,0) null, [hibernatetool] primary key (MESSAGE_ID) [hibernatetool] ); [hibernatetool] [hibernatetool] alter table MESSAGES [hibernatetool] add [hibernatetool] foreign key (NEXT_MESSAGE_ID) [hibernatetool] references MESSAGES; BUILD SUCCESSFUL Total time: 2 seconds </verbatim> 1 Check the DDL that was also exported to the file <code>helloworld-ddl.sql</code> <verbatim> $ more helloworld-ddl.sql drop table MESSAGES; create table MESSAGES ( MESSAGE_ID decimal(20,0) identity, MESSAGE_TEXT varchar(255) null, NEXT_MESSAGE_ID decimal(20,0) null, primary key (MESSAGE_ID) ); alter table MESSAGES add foreign key (NEXT_MESSAGE_ID) references MESSAGES; </verbatim> 1 Run the example with "<code>ant run</code>", and read the log output on the console. %BR%%BR%<i><b>Note:</b> Hibernate logging levels can be varied by changing the settings in the <code>src/etc/log4j.properties</code> and <code>src/etc/META-INF/persistence.xml</code> files.</i> <verbatim> $ ant run Buildfile: build.xml compile: copymetafiles: run: [java] 1 message(s) found: [java] Hello World with JPA BUILD SUCCESSFUL Total time: 2 seconds </verbatim> 1 Call <code>ant run</code> again <verbatim> $ ant run Buildfile: build.xml compile: copymetafiles: run: [java] 2 message(s) found: [java] Hello World with JPA [java] Hello World with JPA BUILD SUCCESSFUL Total time: 2 seconds </verbatim> 1 If you call <code>ant schemaexport</code> again, all tables will be re-created ---+++Example 3 This sample performs more complex insert and retrieval of data against the Virtuoso database. 1 Open your command shell and change to the "<code>ex3</code>" directory 1 The following required files need to be placed in the <code>./lib</code> directory: <verbatim> antlr-2.7.6.jar commons-collections-3.1.jar commons-logging-1.0.4.jar dom4j-1.6.1.jar hibernate3.jar javassist-3.4.GA.jar jta-1.1.jar libs.lst log4j-1.2.15.jar slf4j-api-1.5.10.jar slf4j-api-1.5.2.jar slf4j-jcl-1.5.10.jar virtjdbc4.jar virt_dialect.jar </verbatim> 1 Run the example with "<code>ant run</code>", and read the log output on the console. %BR%%BR%<i><b>Note:</b> Hibernate logging levels can be varied by changing the settings in the <code>src/hibernate.cfg.xml</code> and <code>src/log4j.properties</code> files.</i> <verbatim> $ ant run Buildfile: build.xml clean: [delete] Deleting directory /Users/hughwilliams/hibernate/ex3/bin [mkdir] Created dir: /Users/hughwilliams/hibernate/ex3/bin copy-resources: [copy] Copying 4 files to /Users/hughwilliams/hibernate/ex3/bin [copy] Copied 2 empty directories to 1 empty directory under /Users/hughwilliams/hibernate/ex3/bin compile: [javac] Compiling 4 source files to /Users/hughwilliams/hibernate/ex3/bin [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. run: [java] Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?) [java] Hibernate: select identity_value() [java] Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?) [java] Hibernate: select identity_value() [java] Hibernate: insert into PERSON (age, firstname, lastname) values (?, ?, ?) [java] Hibernate: select identity_value() [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=? [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=? [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=? [java] Hibernate: insert into PERSON_EVENT (PERSON_ID, EVENT_ID) values (?, ?) [java] Hibernate: update PERSON set age=?, firstname=?, lastname=? where PERSON_ID=? [java] Added person 1 to event 2 [java] Hibernate: insert into PERSON (age, firstname, lastname) values (?, ?, ?) [java] Hibernate: select identity_value() [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=? [java] Hibernate: select emailaddre0_.PERSON_ID as PERSON1_0_, emailaddre0_.EMAIL_ADDR as EMAIL2_0_ from PERSON_EMAIL_ADDR emailaddre0_ where emailaddre0_.PERSON_ID=? [java] Hibernate: insert into PERSON_EMAIL_ADDR (PERSON_ID, EMAIL_ADDR) values (?, ?) [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=? [java] Hibernate: select emailaddre0_.PERSON_ID as PERSON1_0_, emailaddre0_.EMAIL_ADDR as EMAIL2_0_ from PERSON_EMAIL_ADDR emailaddre0_ where emailaddre0_.PERSON_ID=? [java] Hibernate: insert into PERSON_EMAIL_ADDR (PERSON_ID, EMAIL_ADDR) values (?, ?) [java] Added two email addresses (value typed objects) to person entity : 1 [java] Hibernate: select event0_.EVENT_ID as EVENT1_0_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from EVENTS event0_ [java] Event: My Event Time: 2010-03-14 03:30:02.0 [java] Event: My Event Time: 2010-03-14 03:30:06.0 BUILD SUCCESSFUL Total time: 5 seconds </verbatim>
sioc:id
0cb164ce199cb5ef77231875f7166d1a
sioc:link
n4:VirtJdbcHibernate
sioc:has_container
n6:VOS
n17:has_services
n16:item
atom:title
VirtJdbcHibernate
sioc:links_to
n10:jar n12:jar n15:zip n22:
atom:source
n6:VOS
atom:author
n7:this
atom:published
2018-04-13T12:06:54Z
atom:updated
2018-05-16T10:00:45Z
sioc:topic
n6:VOS
Subject Item
n4:VOSIndex
sioc:links_to
n4:VirtJdbcHibernate