openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ян Программист <webautoma...@gmail.com>
Subject Re: Still not working
Date Fri, 14 May 2010 09:36:09 GMT
> You can configure OpenJPA to define this table
> 1. Use
>   <property name="openjpa.jdbc.SynchronizeMappings"
> valie="buildSchema(ForeignKeys=true)"/>
>
Not "valie", but "value". Mismatch ;)

>
>   in persistence.xml configuration.

Inacceptable. There is no 100% guarantee that this param would be checked at
runtime.


> 2. Or create the sequence table directly. The following DDL is for MySQL
>
> CREATE TABLE `openjpa_sequence_table` (
>  `ID` tinyint(4) NOT NULL,
>  `SEQUENCE_VALUE` bigint(20) default NULL,
>  PRIMARY KEY  (`ID`)
> )
>
> Nope. That is not acceptable due to terms of future use.


> 3. Run
>   $ java org.apache.openjpa.jdbc.kernel.TableJDBCSeq
> with persistence.xml as property argument to define the table
>
>  Usage: java org.apache.openjpa.jdbc.kernel.TableJDBCSeq
>        [-properties/-p <properties file or resource>]
>        [-<property name> <property value>]*
>        -action/-a <add | drop | get | set> [value]
>
> The most stable variant of all for deployment. I created an external
Eclipse project builder. Here are the arguments:

-classpath /home/webautomator/openjpa-all-2.0.0-beta3.jar
org.apache.openjpa.jdbc.kernel.TableJDBCSeq -p
${project_path}/src/META-INF/persistence.xml


> 4. Please post your persistence.xml if none of the above works
>
> Your expectations where right. It didn't work:

Exception in thread "main" <openjpa-2.0.0-beta3-r422266:926797 fatal user
error> org.apache.openjpa.util.UserException: A JDBC Driver or DataSource
class name must be specified in the ConnectionDriverName property.
    at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:76)
    at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:836)
    at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:594)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.addPrimaryKeyColumn(TableJDBCSeq.java:365)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.buildTable(TableJDBCSeq.java:403)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.endConfiguration(TableJDBCSeq.java:247)
    at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:507)
    at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:432)
    at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:412)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.run(TableJDBCSeq.java:750)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.run(TableJDBCSeq.java:735)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq$1.run(TableJDBCSeq.java:717)
    at
org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:725)
    at
org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:710)
    at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.main(TableJDBCSeq.java:712)

My persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0">
    <!--
        We need to enumerate each persistent class first in the
persistence.xml
        See: http://issues.apache.org/jira/browse/OPENJPA-78
    -->
    <persistence-unit name="none" transaction-type="RESOURCE_LOCAL">
        <mapping-file>reversemapping/orm.xml</mapping-file>
        <class>hellojpa.Message</class>
        <class>relations.Deity</class>
    </persistence-unit>

    <!--
        A persistence unit is a set of listed persistent entities as well
        the configuration of an EntityManagerFactory. We configure each
        example in a separate persistence-unit.
    -->
    <persistence-unit name="hellojpa" transaction-type="RESOURCE_LOCAL">
        <!--
            The default provider can be OpenJPA, or some other product.
            This element is optional if OpenJPA is the only JPA provider
            in the current classloading environment, but can be specified
            in cases where there are multiple JPA implementations available.
        -->
        <!--
        <provider>
            org.apache.openjpa.persistence.PersistenceProviderImpl
        </provider>
        -->

        <!-- We must enumerate each entity in the persistence unit -->
        <class>hellojpa.Message</class>

        <properties>
            <!--
                We can configure the default OpenJPA properties here. They
                happen to be commented out here since the provided examples
                all specify the values via System properties.

            <property name="openjpa.DynamicEnhancementAgent" value="false"/>

            <property name="openjpa.RuntimeUnenhancedClasses"
value="unsupported"/>
            -->

            <property name="openjpa.ConnectionURL"
                value="jdbc:derby:openjpa-database;create=true"/>
            *<property name="openjpa.ConnectionDriverName"
                value="org.apache.derby.jdbc.EmbeddedDriver"/>*
            <property name="openjpa.ConnectionUserName"
                value="user"/>
            <property name="openjpa.ConnectionPassword"
                value="secret"/>

            <property name="openjpa.Sequence"
value="org.apache.openjpa.jdbc.kernel.ClassTableJDBCSeq"/>
        </properties>
    </persistence-unit>

    <!-- persistence unit for the "relations" example -->
    <persistence-unit name="relations" transaction-type="RESOURCE_LOCAL">
        <class>relations.Deity</class>
    </persistence-unit>

    <!-- persistence unit for the "reversemapping" example -->
    <persistence-unit name="reversemapping"
transaction-type="RESOURCE_LOCAL">
        <mapping-file>reversemapping/orm.xml</mapping-file>
    </persistence-unit>
    <persistence-unit name="embeddables" transaction-type="RESOURCE_LOCAL">

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <class>Address</class>
        <class>ContactInfo</class>
        <class>Phone</class>
        <class>User</class>
    </persistence-unit>
</persistence>

John

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message