Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Schema generation script in JPA 2.1(Schema not generated with javax.persistence.schema-generation.create-script-source)
Schema generation script in JPA 2.1 [message #1075936] Tue, 30 July 2013 11:05 Go to next message
Phill Ashworth is currently offline Phill AshworthFriend
Messages: 5
Registered: August 2012
Junior Member
I am trying to use the new JPA 2.1 schema features to have my database schema loaded from a script. I have set "javax.persistence.schema-generation.create-script-source" to the location of my schema DDL but the script does not get run and there are no errors thrown. If I supply a "javax.persistence.sql-load-script-source" to load some initial data this does run but fails as the database tables have not been created.

Maybe I have misunderstood things but I would expect the "..create-script-source" script to be run first to create the database tables etc. then "...sql-load-script-source" to load the data.

persistence.xml below, any suggestions much appreciated.

<persistence version="2.1" xmlns="http ://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http ://xmlns.jcp.org/xml/ns/persistence
             http ://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd">

    <persistence-unit name="myapppu" transaction-type="JTA">
        <jta-data-source>jdbc/myapp</jta-data-source>
        <properties>
            <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.H2Platform"/>
            <property name="javax.persistence.schema-generation.database.action" value="create"/>
            <property name="javax.persistence.schema-generation.scripts.action" value="none"/>
            <property name="javax.persistence.schema-generation.create-source" value="script"/>
            <property name="javax.persistence.schema-generation.create-script-source" value="file:etc/schema/schema-1.0.sql"/>
			<!--<property name="javax.persistence.sql-load-script-source" value="file:etc/data/test-data.sql"/>-->
            <property name="eclipselink.deploy-on-startup" value="true"/>
            <property name="eclipselink.logging.level" value="fine"/>
        </properties>
    </persistence-unit>

</persistence>

PS. I'm using embedded Glassfish 4 which reports the EclipseLink version as - Eclipse Persistence Services - 2.5.0.v20130507-3faac2b

Re: Schema generation script in JPA 2.1 [message #1076061 is a reply to message #1075936] Tue, 30 July 2013 16:22 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
What is in the script? EclipseLink should throw an exception if it cannot load the script file, so I would suggest turning EclipseLink logging to Finest and check the logs to see if the script you have specified is being executed or if there are some issues when running the script that might be preventing the tables from being fully created.

Best Regards,
Chris
Re: Schema generation script in JPA 2.1 [message #1076128 is a reply to message #1076061] Tue, 30 July 2013 19:15 Go to previous message
Phill Ashworth is currently offline Phill AshworthFriend
Messages: 5
Registered: August 2012
Junior Member
Thanks I've got the errors now and it seems it doesn't like the line breaks in my SQL file.

My schema is generated by a data modelling tool with table definitions like below. I let JPA generate the DDL script and I see it has each table definition on a single line. Is there any way around this or does each statement have to be on a single line?

CREATE TABLE "language" (
"language_code" char(2) NOT NULL,
"language_description" varchar(50) NOT NULL,
CONSTRAINT "language_pkey" PRIMARY KEY ("language_code") 
);
Previous Topic:Sequences in SQL Server 2012 + JPA + Eclipselink
Next Topic:AdditionalCriteria in ServerSession
Goto Forum:
  


Current Time: Fri Apr 26 11:23:24 GMT 2024

Powered by FUDForum. Page generated in 0.03560 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top