{"id":295,"date":"2009-12-09T18:06:59","date_gmt":"2009-12-09T18:06:59","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=295"},"modified":"2010-01-23T11:23:52","modified_gmt":"2010-01-23T11:23:52","slug":"using-oracle-specific-features-in-jpaeclipselink","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=295","title":{"rendered":"Using Oracle Specific features in JPA with Eclipselink"},"content":{"rendered":"<p>To use Oracle specific features in JPA with Eclipselink, such as using sequences for ID generation as described in <a title=\"http:\/\/salientsoft.co.uk\/?p=209\" href=\"http:\/\/salientsoft.co.uk\/?p=209\"><strong>this example here<\/strong><\/a><strong>,<\/strong> it is necessary to set the correct property in persistence.xml to ensure that JPA\/Eclipselink knows that an Oracle database is in use. By default, it does not discover this automatically and resorts to using table based ID generation even if you turn sequences on as per the above example.<\/p>\n<p>A sample persistence.xml with the correct properties follows :-<\/p>\n<pre>\r\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;persistence version=\"1.0\"\r\n\u00a0xmlns=\"<a href=\"http:\/\/java.sun.com\/xml\/ns\/persistence\">http:\/\/java.sun.com\/xml\/ns\/persistence<\/a>\"\r\n\u00a0xmlns:xsi=\"<a href=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\">http:\/\/www.w3.org\/2001\/XMLSchema-instance<\/a>\"\r\n\u00a0xsi:schemaLocation=\"<a href=\"http:\/\/java.sun.com\/xml\/ns\/persistence\">http:\/\/java.sun.com\/xml\/ns\/persistence<\/a>\r\n\u00a0<a href=\"http:\/\/java.sun.com\/xml\/ns\/persistence\/persistence_1_0.xsd\">http:\/\/java.sun.com\/xml\/ns\/persistence\/persistence_1_0.xsd<\/a>\"&gt;\r\n\u00a0&lt;persistence-unit name=\"JPATest\" transaction-type=\"RESOURCE_LOCAL\"&gt;\r\n\u00a0\u00a0&lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;\/provider&gt;\r\n\u00a0\u00a0&lt;non-jta-data-source&gt;jdbc\/JPATestPool&lt;\/non-jta-data-source&gt;\r\n\u00a0\u00a0&lt;mapping-file&gt;META-INF\/orm.xml&lt;\/mapping-file&gt;\r\n\u00a0\u00a0&lt;class&gt;uk.co.salientsoft.jpatest.domain.UserInfo&lt;\/class&gt;\r\n\u00a0\u00a0&lt;properties&gt;\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.target-server\" value=\"SunAS9\" \/&gt;\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.logging.level\" value=\"FINEST\" \/&gt;\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.session-name\" value=\"JPATestSession\" \/&gt;\r\n\r\n\u00a0\u00a0\u00a0&lt;!-- Ensure Eclipselink knows we have an Oracle Database\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 so that Oracle specific features work correctly --&gt;\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.target-database\" value=\"Oracle\"\/&gt;\r\n\r\n\u00a0\u00a0\u00a0&lt;!-- This will cause EclipseLink to create the database schema\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 automatically on every run.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 You can also do this from the JPA Tools\/Create Tables from Entities\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 project context menu option in Eclipse, which may well be preferrable--&gt;\r\n\u00a0\u00a0\u00a0&lt;!--\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.ddl-generation\" value=\"drop-and-create-tables\" \/&gt;\r\n\u00a0\u00a0\u00a0&lt;property name=\"eclipselink.ddl-generation.output-mode\" value=\"database\" \/&gt;\r\n\u00a0\u00a0\u00a0--&gt;\r\n\r\n\u00a0\u00a0&lt;\/properties&gt;\r\n\u00a0&lt;\/persistence-unit&gt;\r\n&lt;\/persistence&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To use Oracle specific features in JPA with Eclipselink, such as using sequences for ID generation as described in this example here, it is necessary to set the correct property in persistence.xml to ensure that JPA\/Eclipselink knows that an Oracle database is in use. By default, it does not discover this automatically and resorts to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[35,182,29,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/295"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295"}],"version-history":[{"count":10,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":298,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/295\/revisions\/298"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}