Hibernate,Oracle,Play:无法构建EntityManagerFactory错误

时间:2015-08-04 21:40:12

标签: oracle hibernate jpa playframework-2.0

在尝试将它与Oracle一起使用时,我从Hibernate得到了一个非常模糊的例外。(它在MySQL中正常工作)

我有以下配置:

Play Framework:2.3.7
ojdbc14.jar的
休眠:4.3.8.Final
我正在使用Oracle 10i

应用程序设法连接,但在尝试构建实体管理器时失败。 我尝试手动构建它,但是在使用Play的注释 @ play.db.jpa.Transactional 时出现了同样的错误 例如:通过原始JDBC访问正常工作。

我在application.conf中的数据库设置:

db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:@IP:1521:SID"
db.default.user=USER_NAME
db.default.pass=ROOT
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit

My Persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>

    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
    </properties>

</persistence-unit>

</persistence>

以下是例外:

play.api.UnexpectedException: Unexpected exception[PersistenceException: Unable to build entity manager factory]
at   play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.11-2.3.7.jar:2.3.7]
at    play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
at    play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
at    play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(App    licationProvider.scala:128) ~[play_2.11-2.3.7.jar:2.3.7]
Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:83) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:38) ~[play-java-jpa_2.11-2.3.7.jar:2.3.7]
Caused by: java.lang.NullPointerException: null
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]

///////////////////////////////////////////// <无线电通信/> 更新:
休眠接收的属性是:

 0 = {HashMap$Node@10729} "gopherProxySet" -> "false"
1 = {HashMap$Node@10730} "awt.toolkit" -> "sun.lwawt.macosx.LWCToolkit"
2 = {HashMap$Node@10731} "file.encoding.pkg" -> "sun.io"
3 = {HashMap$Node@10732} "java.specification.version" -> "1.8"
4 = {HashMap$Node@10733} "sun.cpu.isalist" -> 
5 = {HashMap$Node@10734} "sun.jnu.encoding" -> "UTF-8"
6 = {HashMap$Node@10735} "hibernate.dialect" -> "org.hibernate.dialect.Oracle10gDialect"
7 = {HashMap$Node@10736} "java.class.path" -> "/Users/rodrigoarantes1/Library/Application Support/IntelliJIdea14/Scala/launcher/sbt-launch.jar:/Applications/IntelliJ IDEA 14.app/Contents/lib/idea_rt.jar"
8 = {HashMap$Node@10737} "java.naming.provider.url" -> "/"
9 = {HashMap$Node@10738} "sbt.global.base" -> "/private/var/folders/8l/k806t46d2fl5sq2rt6gzp7z00000gp/T/sbt-global-plugin1stub"
10 = {HashMap$Node@10739} "java.vm.vendor" -> "Oracle Corporation"
11 = {HashMap$Node@10740} "sun.arch.data.model" -> "64"
12 = {HashMap$Node@10741} "jline.shutdownhook" -> "false"
13 = {HashMap$Node@10742} "java.vendor.url" -> "http://java.oracle.com/"
15 = {HashMap$Node@10744} "javax.persistence.jdbc.user" -> "USERNAME"
16 = {HashMap$Node@10745} "hibernate.transaction.factory_class" -> "class org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory"
17 = {HashMap$Node@10746} "javax.persistence.jdbc.url" -> "jdbc:oracle:thin:@127.0.0.1:1521:XE"
18 = {HashMap$Node@10747} "jline.terminal" -> "none"
19 = {HashMap$Node@10748} "os.name" -> "Mac OS X"
20 = {HashMap$Node@10749} "java.vm.specification.version" -> "1.8"
21 = {HashMap$Node@10750} "sun.java.launcher" -> "SUN_STANDARD"
23 = {HashMap$Node@10752} "sun.boot.library.path" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib"
24 = {HashMap$Node@10753} "sun.java.command" -> "xsbt.boot.Boot run"
25 = {HashMap$Node@10754} "http.nonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"
26 = {HashMap$Node@10755} "sun.cpu.endian" -> "little"
27 = {HashMap$Node@10756} "user.home" -> "/Users/rodrigoarantes1"
28 = {HashMap$Node@10757} "user.language" -> "en"
29 = {HashMap$Node@10758} "java.specification.vendor" -> "Oracle Corporation"
30 = {HashMap$Node@10759} "java.home" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre"
31 = {HashMap$Node@10760} "file.separator" -> "/"
32 = {HashMap$Node@10761} "line.separator" -> "\n"
33 = {HashMap$Node@10762} "java.vm.specification.vendor" -> "Oracle Corporation"
34 = {HashMap$Node@10763} "java.specification.name" -> "Java Platform API Specification"
35 = {HashMap$Node@10764} "java.awt.graphicsenv" -> "sun.awt.CGraphicsEnvironment"
36 = {HashMap$Node@10765} "javax.persistence.jdbc.driver" -> "oracle.jdbc.driver.OracleDriver"
37 = {HashMap$Node@10766} "sun.boot.class.path" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/classes"
38 = {HashMap$Node@10767} "jline.esc.timeout" -> "0"
39 = {HashMap$Node@10768} "sun.management.compiler" -> "HotSpot 64-Bit Tiered Compilers"
40 = {HashMap$Node@10769} "ftp.nonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"
41 = {HashMap$Node@10770} "java.runtime.version" -> "1.8.0_45-b14"
42 = {HashMap$Node@10771} "java.naming.factory.initial" -> "tyrex.naming.MemoryContextFactory"
43 = {HashMap$Node@10772} "user.name" -> "rodrigoarantes1"
44 = {HashMap$Node@10773} "path.separator" -> ":"
45 = {HashMap$Node@10774} "os.version" -> "10.10.4"
46 = {HashMap$Node@10775} "java.endorsed.dirs" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/endorsed"
47 = {HashMap$Node@10776} "java.runtime.name" -> "Java(TM) SE Runtime Environment"
48 = {HashMap$Node@10777} "sbt.log.noformat" -> "true"
49 = {HashMap$Node@10778} "hibernate.ejb.persistenceUnitName" -> "oraclePersistenceUnit"
50 = {HashMap$Node@10779} "file.encoding" -> "UTF8"
51 = {HashMap$Node@10780} "sun.nio.ch.bugLevel" -> 
52 = {HashMap$Node@10781} "java.vm.name" -> "Java HotSpot(TM) 64-Bit Server VM"
53 = {HashMap$Node@10782} "java.vendor.url.bug" -> "http://bugreport.sun.com/bugreport/"
54 = {HashMap$Node@10783} "java.io.tmpdir" -> "/var/folders/8l/k806t46d2fl5sq2rt6gzp7z00000gp/T/"
55 = {HashMap$Node@10784} "java.version" -> "1.8.0_45"
57 = {HashMap$Node@10786} "os.arch" -> "x86_64"
58 = {HashMap$Node@10787} "java.vm.specification.name" -> "Java Virtual Machine Specification"
59 = {HashMap$Node@10788} "java.awt.printerjob" -> "sun.lwawt.macosx.CPrinterJob"
60 = {HashMap$Node@10789} "sun.os.patch.level" -> "unknown"
61 = {HashMap$Node@10790} "java.library.path" -> ":/Library/Oracle/instantclient_11_2:/Users/rodrigoarantes1/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.:/Users/rodrigoarantes1/SourceTree-Repos/Project/target/native_libraries/64bits"
62 = {HashMap$Node@10791} "java.vendor" -> "Oracle Corporation"
63 = {HashMap$Node@10792} "java.vm.info" -> "mixed mode"
64 = {HashMap$Node@10793} "java.vm.version" -> "25.45-b02"
65 = {HashMap$Node@10794} "hibernate.bytecode.use_reflection_optimizer" -> "false"
66 = {HashMap$Node@10795} "hibernate.connection.datasource" -> "OracleDS"
67 = {HashMap$Node@10796} "sun.io.unicode.encoding" -> "UnicodeBig"
68 = {HashMap$Node@10797} "java.ext.dirs" -> "/Users/rodrigoarantes1/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"
69 = {HashMap$Node@10798} "javax.persistence.jdbc.password" -> "ROOT"
70 = {HashMap$Node@10799} "java.class.version" -> "52.0"
71 = {HashMap$Node@10800} "socksNonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"

更多详情: hibernate生成的元数据是:

connection = {OracleConnection@10996} 
 url = {String@10997} "jdbc:oracle:thin:@127.0.0.1:1521:XE"
 user = {String@10998} "USER_NAME"
 password = {String@10999} "ROOT"
 database = {String@11000} "127.0.0.1:1521:XE"
 auto_commit = true
 protocol = {String@11001} "thin"
 db_access = {TTC7Protocol@11002} 
 conversion = {TTCConversion@11003} 
 lob_dbaccess = null
 XA_wants_error = false
 UsingXA = false
 m_txn_mode = 0
 fdo = null
 big_endian = null
 statement_table = {Hashtable@11004}  size = 0
 closed = false
 m_clientIdSet = false
 m_clientId = null
 default_batch = 1
 default_row_prefetch = 10
 report_remarks = false
 include_synonyms = false
 restrict_getTables = false
 m_accumulateBatchResult = true
 m_j2ee13Compliant = false
 m_v8compatible = false
 looseTimestampDateCheck = false
 dataSizeScale = 1
 noCachingBuffer = false
 trans_level = 2
 map = null
 m_javaObjectMap = {Hashtable@11005}  size = 0
 descriptorCache = {Hashtable@11006}  size = 0
 statement_holding_line = null
 m_dbMetaData = {OracleDatabaseMetaData@10994} 
  connection = {OracleConnection@10996} 
   url = {String@10997} "jdbc:oracle:thin:@127.0.0.1:1521:XE"
   user = {String@10998} "USER_NAME"
   password = {String@10999} "ROOT"
   database = {String@11000} "127.0.0.1:1521:XE"
   auto_commit = true
   protocol = {String@11001} "thin"
   db_access = {TTC7Protocol@11002} 
   conversion = {TTCConversion@11003} 
   lob_dbaccess = null
   XA_wants_error = false
   UsingXA = false
   m_txn_mode = 0
   fdo = null
   big_endian = null
   statement_table = {Hashtable@11004}  size = 0
   closed = false
   m_clientIdSet = false
   m_clientId = null
   default_batch = 1
   default_row_prefetch = 10
   report_remarks = false
   include_synonyms = false
   restrict_getTables = false
   m_accumulateBatchResult = true
   m_j2ee13Compliant = false
   m_v8compatible = false
   looseTimestampDateCheck = false
   dataSizeScale = 1
   noCachingBuffer = false
   trans_level = 2
   map = null
   m_javaObjectMap = {Hashtable@11005}  size = 0
   descriptorCache = {Hashtable@11006}  size = 0
   statement_holding_line = null
   m_dbMetaData = {OracleDatabaseMetaData@10994} 
    connection = {OracleConnection@10996} 
     url = {String@10997} "jdbc:oracle:thin:@127.0.0.1:1521:XE"
     user = {String@10998} "USER_NAME"
     password = {String@10999} "ROOT"
     database = {String@11000} "127.0.0.1:1521:XE"
     auto_commit = true
     protocol = {String@11001} "thin"
     db_access = {TTC7Protocol@11002} 
     conversion = {TTCConversion@11003} 
     lob_dbaccess = null
     XA_wants_error = false
     UsingXA = false
     m_txn_mode = 0
     fdo = null
     big_endian = null
     statement_table = {Hashtable@11004}  size = 0
     closed = false
     m_clientIdSet = false
     m_clientId = null
     default_batch = 1
     default_row_prefetch = 10
     report_remarks = false
     include_synonyms = false
     restrict_getTables = false
     m_accumulateBatchResult = true
     m_j2ee13Compliant = false
     m_v8compatible = false
     looseTimestampDateCheck = false
     dataSizeScale = 1
     noCachingBuffer = false
     trans_level = 2
     map = null
     m_javaObjectMap = {Hashtable@11005}  size = 0
     descriptorCache = {Hashtable@11006}  size = 0
     statement_holding_line = null
     m_dbMetaData = {OracleDatabaseMetaData@10994} 
     physicalStatus = true
     logicalHandle = false
     m_opc = null
     m_opc_oc = null
     m_osql = {OracleSql@11007} 
     m_warning = null
     m_readOnly = false
     m_startTime = 0
     statementCache = null
     m_stmtClearMetaData = false
     m_process_escapes = true
     m_defaultAutoRefetch = true
     m_occ = null
     m_privData = null
     defaultFixedString = false
     m_svptStmt = null
     wrapper = null
     connectionProperties = {Properties@11008}  size = 3
     timeout = null
     m_clientData = null
     m_sessionTimeZone = null
     m_dbTzCalendar = null
    procedureResultUnknown = 0
    procedureNoResult = 1
    procedureReturnsResult = 2
    procedureColumnUnknown = 0
    procedureColumnIn = 1
    procedureColumnInOut = 2
    procedureColumnOut = 4
    procedureColumnReturn = 5
    procedureColumnResult = 3
    procedureNoNulls = 0
    procedureNullable = 1
    procedureNullableUnknown = 2
    columnNoNulls = 0
    columnNullable = 1
    columnNullableUnknown = 2
    versionColumnUnknown = 0
    versionColumnNotPseudo = 1
    versionColumnPseudo = 2
    importedKeyCascade = 0
    importedKeyRestrict = 1
    importedKeySetNull = 2
    typeNoNulls = 0
    typeNullable = 1
    typeNullableUnknown = 2
    typePredNone = 0
    typePredChar = 1
    typePredBasic = 2
    typeSearchable = 3
    tableIndexStatistic = 0
    tableIndexClustered = 1
    tableIndexHashed = 2
    tableIndexOther = 3
    attributeNoNulls = 0
    attributeNullable = 1
    attributeNullableUnknown = 2
    sqlStateXOpen = 1
    sqlStateSQL99 = 2
   physicalStatus = true
   logicalHandle = false
   m_opc = null
   m_opc_oc = null
   m_osql = {OracleSql@11007} 
    isV8Compatible = false
    current_argument = 1
    parameterCount = 0
    i = 26
    length = 26
    c = 'E' 69
    first = false
    in_string = false
    odbc_sql = {String@11009} "SET TRANSACTION READ WRITE"
    oracle_sql = {StringBuffer@11010} "SET TRANSACTION READ WRITE"
    token_buffer = {StringBuffer@11011} ""
    isLocate = false
   m_warning = null
   m_readOnly = false
   m_startTime = 0
   statementCache = null
   m_stmtClearMetaData = false
   m_process_escapes = true
   m_defaultAutoRefetch = true
   m_occ = null
   m_privData = null
   defaultFixedString = false
   m_svptStmt = null
   wrapper = null
   connectionProperties = {Properties@11008}  size = 3
    0 = {Hashtable$Entry@11018} "user" -> "USER_NAME"
    1 = {Hashtable$Entry@11019} "dll" -> "ocijdbc9"
    2 = {Hashtable$Entry@11020} "protocol" -> "thin"
   timeout = null
   m_clientData = null
   m_sessionTimeZone = null
   m_dbTzCalendar = null
  procedureResultUnknown = 0
  procedureNoResult = 1
  procedureReturnsResult = 2
  procedureColumnUnknown = 0
  procedureColumnIn = 1
  procedureColumnInOut = 2
  procedureColumnOut = 4
  procedureColumnReturn = 5
  procedureColumnResult = 3
  procedureNoNulls = 0
  procedureNullable = 1
  procedureNullableUnknown = 2
  columnNoNulls = 0
  columnNullable = 1
  columnNullableUnknown = 2
  versionColumnUnknown = 0
  versionColumnNotPseudo = 1
  versionColumnPseudo = 2
  importedKeyCascade = 0
  importedKeyRestrict = 1
  importedKeySetNull = 2
  typeNoNulls = 0
  typeNullable = 1
  typeNullableUnknown = 2
  typePredNone = 0
  typePredChar = 1
  typePredBasic = 2
  typeSearchable = 3
  tableIndexStatistic = 0
  tableIndexClustered = 1
  tableIndexHashed = 2
  tableIndexOther = 3
  attributeNoNulls = 0
  attributeNullable = 1
  attributeNullableUnknown = 2
  sqlStateXOpen = 1
  sqlStateSQL99 = 2
 physicalStatus = true
 logicalHandle = false
 m_opc = null
 m_opc_oc = null
 m_osql = {OracleSql@11007} 
  isV8Compatible = false
  current_argument = 1
  parameterCount = 0
  i = 26
  length = 26
  c = 'E' 69
  first = false
  in_string = false
  odbc_sql = {String@11009} "SET TRANSACTION READ WRITE"
  oracle_sql = {StringBuffer@11010} "SET TRANSACTION READ WRITE"
  token_buffer = {StringBuffer@11011} ""
  isLocate = false
 m_warning = null
 m_readOnly = false
 m_startTime = 0
 statementCache = null
 m_stmtClearMetaData = false
 m_process_escapes = true
 m_defaultAutoRefetch = true
 m_occ = null
 m_privData = null
 defaultFixedString = false
 m_svptStmt = null
 wrapper = null
 connectionProperties = {Properties@11008}  size = 3
 timeout = null
 m_clientData = null
 m_sessionTimeZone = null
 m_dbTzCalendar = null
procedureResultUnknown = 0
procedureNoResult = 1
procedureReturnsResult = 2
procedureColumnUnknown = 0
procedureColumnIn = 1
procedureColumnInOut = 2
procedureColumnOut = 4
procedureColumnReturn = 5
procedureColumnResult = 3
procedureNoNulls = 0
procedureNullable = 1
procedureNullableUnknown = 2
columnNoNulls = 0
columnNullable = 1
columnNullableUnknown = 2
versionColumnUnknown = 0
versionColumnNotPseudo = 1
versionColumnPseudo = 2
importedKeyCascade = 0
importedKeyRestrict = 1
importedKeySetNull = 2
typeNoNulls = 0
typeNullable = 1
typeNullableUnknown = 2
typePredNone = 0
typePredChar = 1
typePredBasic = 2
typeSearchable = 3
tableIndexStatistic = 0
tableIndexClustered = 1
tableIndexHashed = 2
tableIndexOther = 3
attributeNoNulls = 0
attributeNullable = 1
attributeNullableUnknown = 2
sqlStateXOpen = 1
sqlStateSQL99 = 2

Hibernate抛出异常:
文件:JdbcServicesImpl.java
方法:meta.supportsNamedParameters();

SQLState = null
vendorCode = 17023
next = null
detailMessage = {String@13599} "Unsupported feature"
cause = {SQLException@13595} "java.sql.SQLException: Unsupported feature"
stackTrace = {StackTraceElement[0]@13600} 
suppressedExceptions = {Collections$UnmodifiableRandomAccessList@13601}  size = 0

有人可以帮我弄清问题可能是什么以及如何解决? 任何帮助都非常感谢。

谢谢

2 个答案:

答案 0 :(得分:0)

由于我没有使用游戏,我的答案不是复制和粘贴,但它会告诉你如何做到这一点。

您的持久性单元中似乎缺少很多属性。您没有提供必填字段,如用户名,密码,网址架构等。请查看:

https://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/configuration.html

hsqldb的一个例子来自上面的文档:

    <persistence>
   <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
      <class>org.hibernate.ejb.test.Cat</class>
      <class>org.hibernate.ejb.test.Distributor</class>
      <class>org.hibernate.ejb.test.Item</class>
      <properties>
         <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
         <property name="javax.persistence.jdbc.user" value="sa"/>
         <property name="javax.persistence.jdbc.password" value=""/>
         <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:."/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/
         <property name="hibernate.max_fetch_depth" value="3"/>

         <!-- cache configuration -->
         <property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/>
         <property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors" value="read-write, RegionName"/>

         <!-- alternatively to <class> and <property> declarations, you can use a regular hibernate.cfg.xml file -->
         <!-- property name="hibernate.ejb.cfgfile" value="/org/hibernate/ejb/test/hibernate.cfg.xml"/ -->
      </properties>
   </persistence-unit>
</persistence>

答案 1 :(得分:0)

该问题与Oracle驱动程序有关。

我的原始配置适用于驱动程序ojdbc7.jar

所以我的play / jpa配置保持为:

<强> application.conf

db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:@IP:1521:SID"
db.default.user=USER_NAME
db.default.pass=ROOT
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit


的persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>

    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
    </properties>

</persistence-unit>

</persistence>


我希望它有助于某人

编辑:

我也尝试过使用ojdbc14.jar,因为我需要连接oracle 8i服务器。
您只需将以下属性添加到persistence.xml

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>

由于