Create DB DDL scripts instead of building database

View: New views
10 Messages — Rating Filter:   Alert me  

Create DB DDL scripts instead of building database

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry - me again.

I found this http://www.nabble.com/Character-set---encoding-in-tables---td21908086.html, read this http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29 and ended up with this in my persistence.xml

                        <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                        <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
                        <property name="eclipselink.application-location" value="H:\new_workspace\ids2_databaseBuilder\schema\"/>
                        <property name="eclipselink.create-ddl-jdbc-file-name" value="create_ddl.sql"/>
                        <property name="eclipselink.drop-ddl-jdbc-file-name" value="drop_ddl.sql"/>

but create Tables from Entities still keeps wiping out my database and doesn't generate the scripts as expected.

Re: Create DB DDL scripts instead of building database

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you running in JavaSE or in some kind of application server (and if so,
which one?

Do you see the sql-script generated as well?

RogerV wrote:

> Sorry - me again.
>
> I found this
> http://www.nabble.com/Character-set---encoding-in-tables---td21908086.html,
> read this
> http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29 and
> ended up with this in my persistence.xml
>
> <property name="eclipselink.ddl-generation"
> value="drop-and-create-tables"/>
> <property name="eclipselink.ddl-generation.output-mode"
> value="sql-script"/>
> <property name="eclipselink.application-location"
> value="H:\new_workspace\ids2_databaseBuilder\schema\"/>
> <property name="eclipselink.create-ddl-jdbc-file-name"
> value="create_ddl.sql"/>
> <property name="eclipselink.drop-ddl-jdbc-file-name"
> value="drop_ddl.sql"/>
>
> but create Tables from Entities still keeps wiping out my database and
> doesn't generate the scripts as expected.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Create DB DDL scripts instead of building database

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


tware wrote:
Are you running in JavaSE or in some kind of application server (and if so,
which one?
Running in JavaSE - I'm actually running within Eclipse Galileo.

Do you see the sql-script generated as well?
I see some SQL - but it doesn't look any different than it did previously before I changed the persistence.xml - for example

[EL Fine]: Connection(25515362)--ALTER TABLE Hardware DROP FOREIGN KEY FK_Hardware_assemblyId
[EL Fine]: Connection(25515362)--ALTER TABLE PEcu DROP FOREIGN KEY FK_PEcu_platformId
[EL Fine]: Connection(25515362)--DROP TABLE Software
[EL Fine]: Connection(25515362)--CREATE TABLE Software (predecessor VARCHAR(64), successor VARCHAR(64), fileName VARCHAR(32), fileType VARCHAR(8), sequence INTEGER UNIQUE NOT NULL, softwareId VARCHAR(64) UNIQUE NOT NULL, hardwareId VARCHAR(64) UNIQUE NOT NULL, assemblyId VARCHAR(64) UNIQUE NOT NULL, platformId INTEGER UNIQUE NOT NULL, txAddress VARCHAR(3) UNIQUE NOT NULL, busId INTEGER UNIQUE NOT NULL, PRIMARY KEY (sequence, softwareId, hardwareId, assemblyId, platformId, txAddress, busId))

Regards

Re: Create DB DDL scripts instead of building database

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I appologize for not being clear.

Do you see the SQL scripts being generated?  (i.e. Do you see create_ddl.sql and
drop_ddl.sql being generated?)

Also, what version of EclipseLink are you running on?

RogerV wrote:

>
>
> tware wrote:
>> Are you running in JavaSE or in some kind of application server (and if
>> so,
>> which one?
>>
>
> Running in JavaSE - I'm actually running within Eclipse Galileo.
>
>
>
>> Do you see the sql-script generated as well?
>>
>
> I see some SQL - but it doesn't look any different than it did previously
> before I changed the persistence.xml - for example
>
> [EL Fine]: Connection(25515362)--ALTER TABLE Hardware DROP FOREIGN KEY
> FK_Hardware_assemblyId
> [EL Fine]: Connection(25515362)--ALTER TABLE PEcu DROP FOREIGN KEY
> FK_PEcu_platformId
> [EL Fine]: Connection(25515362)--DROP TABLE Software
> [EL Fine]: Connection(25515362)--CREATE TABLE Software (predecessor
> VARCHAR(64), successor VARCHAR(64), fileName VARCHAR(32), fileType
> VARCHAR(8), sequence INTEGER UNIQUE NOT NULL, softwareId VARCHAR(64) UNIQUE
> NOT NULL, hardwareId VARCHAR(64) UNIQUE NOT NULL, assemblyId VARCHAR(64)
> UNIQUE NOT NULL, platformId INTEGER UNIQUE NOT NULL, txAddress VARCHAR(3)
> UNIQUE NOT NULL, busId INTEGER UNIQUE NOT NULL, PRIMARY KEY (sequence,
> softwareId, hardwareId, assemblyId, platformId, txAddress, busId))
>
> Regards
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Create DB DDL scripts instead of building database

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


tware wrote:
Do you see the SQL scripts being generated?  (i.e. Do you see create_ddl.sql and
drop_ddl.sql being generated?)
No. There no mention of create_ddl.sql or drop_ddl.sql in the console output. Scanning the harddrive - no sign of them either.

Also, what version of EclipseLink are you running on?
Project properties shows EclipseLink 1.1.x. Looking at the persistence jars in the eclipse/plugin directory, looks like 1.1.2.v20060612-r4475. If this isn't the information you need, you'll need to tell me where to look I'm afraid.

Regards

RogerV wrote:
>
>
> tware wrote:
>> Are you running in JavaSE or in some kind of application server (and if
>> so,
>> which one?
>>
>
> Running in JavaSE - I'm actually running within Eclipse Galileo.
>
>
>
>> Do you see the sql-script generated as well?
>>
>
> I see some SQL - but it doesn't look any different than it did previously
> before I changed the persistence.xml - for example
>
> [EL Fine]: Connection(25515362)--ALTER TABLE Hardware DROP FOREIGN KEY
> FK_Hardware_assemblyId
> [EL Fine]: Connection(25515362)--ALTER TABLE PEcu DROP FOREIGN KEY
> FK_PEcu_platformId
> [EL Fine]: Connection(25515362)--DROP TABLE Software
> [EL Fine]: Connection(25515362)--CREATE TABLE Software (predecessor
> VARCHAR(64), successor VARCHAR(64), fileName VARCHAR(32), fileType
> VARCHAR(8), sequence INTEGER UNIQUE NOT NULL, softwareId VARCHAR(64) UNIQUE
> NOT NULL, hardwareId VARCHAR(64) UNIQUE NOT NULL, assemblyId VARCHAR(64)
> UNIQUE NOT NULL, platformId INTEGER UNIQUE NOT NULL, txAddress VARCHAR(3)
> UNIQUE NOT NULL, busId INTEGER UNIQUE NOT NULL, PRIMARY KEY (sequence,
> softwareId, hardwareId, assemblyId, platformId, txAddress, busId))
>
> Regards
_______________________________________________
eclipselink-users mailing list
eclipselink-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Re: Create DB DDL scripts instead of building database

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Roger,

   I just ran a quick test and I seem to get the expected behavior.

   How is your persistence unit configured?  Where are the classes?  Where is
the persistence.xml?  Is it possible to post the full persistence.xml?  Is your
application OSGi?

-Tom

RogerV wrote:

>
>
> tware wrote:
>> Do you see the SQL scripts being generated?  (i.e. Do you see
>> create_ddl.sql and
>> drop_ddl.sql being generated?)
>>
>
> No. There no mention of create_ddl.sql or drop_ddl.sql in the console
> output. Scanning the harddrive - no sign of them either.
>
>
>
>> Also, what version of EclipseLink are you running on?
>>
>
> Project properties shows EclipseLink 1.1.x. Looking at the persistence jars
> in the eclipse/plugin directory, looks like 1.1.2.v20060612-r4475. If this
> isn't the information you need, you'll need to tell me where to look I'm
> afraid.
>
> Regards
>
> RogerV wrote:
>>
>> tware wrote:
>>> Are you running in JavaSE or in some kind of application server (and if
>>> so,
>>> which one?
>>>
>> Running in JavaSE - I'm actually running within Eclipse Galileo.
>>
>>
>>
>>> Do you see the sql-script generated as well?
>>>
>> I see some SQL - but it doesn't look any different than it did previously
>> before I changed the persistence.xml - for example
>>
>> [EL Fine]: Connection(25515362)--ALTER TABLE Hardware DROP FOREIGN KEY
>> FK_Hardware_assemblyId
>> [EL Fine]: Connection(25515362)--ALTER TABLE PEcu DROP FOREIGN KEY
>> FK_PEcu_platformId
>> [EL Fine]: Connection(25515362)--DROP TABLE Software
>> [EL Fine]: Connection(25515362)--CREATE TABLE Software (predecessor
>> VARCHAR(64), successor VARCHAR(64), fileName VARCHAR(32), fileType
>> VARCHAR(8), sequence INTEGER UNIQUE NOT NULL, softwareId VARCHAR(64)
>> UNIQUE
>> NOT NULL, hardwareId VARCHAR(64) UNIQUE NOT NULL, assemblyId VARCHAR(64)
>> UNIQUE NOT NULL, platformId INTEGER UNIQUE NOT NULL, txAddress VARCHAR(3)
>> UNIQUE NOT NULL, busId INTEGER UNIQUE NOT NULL, PRIMARY KEY (sequence,
>> softwareId, hardwareId, assemblyId, platformId, txAddress, busId))
>>
>> Regards
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@...
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Create DB DDL scripts instead of building database

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


tware wrote:
Hi Roger,

   I just ran a quick test and I seem to get the expected behavior.

   How is your persistence unit configured?  Where are the classes?  Where is
the persistence.xml?  Is it possible to post the full persistence.xml?  Is your
application OSGi?

-Tom
Hi Tom

Persistence.xml is attached below. It's in the META-INF directory which is in the root of my source directory. It's in the right place as I invalidated the xml by removing an end tag and tried to re-run the DDL generation and it failed because of the missing end tag so it's reading the right file. The entity classes are in sub-directories of the source root. The application is not OSGi.

Regards
 
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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_1_0.xsd">
        <persistence-unit name="ids2_develop" transaction-type="RESOURCE_LOCAL">
       
        <description>Eclipse</description>
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>com.blackbox.entities.db.Vw_Ecu</class>
        <class>com.blackbox.entities.db.SwimPart</class>
        <class>com.blackbox.entities.db.SoftwarePK</class>
        <class>com.blackbox.entities.db.Software</class>
        <class>com.blackbox.entities.db.Platform</class>
        <class>com.blackbox.entities.db.PEcuTextPK</class>
        <class>com.blackbox.entities.db.PEcuText</class>
        <class>com.blackbox.entities.db.PEcuAcronymPK</class>
        <class>com.blackbox.entities.db.PEcuAcronym</class>
        <class>com.blackbox.entities.db.PEcu</class>
        <class>com.blackbox.entities.db.PBusPK</class>
        <class>com.blackbox.entities.db.PBus</class>
        <class>com.blackbox.entities.db.HardwarePK</class>
        <class>com.blackbox.entities.db.Hardware</class>
        <class>com.blackbox.entities.db.CusCom</class>
        <class>com.blackbox.entities.db.CCFParameter</class>
        <class>com.blackbox.entities.db.CCFGroup</class>
        <class>com.blackbox.entities.db.Bus</class>
        <class>com.blackbox.entities.db.BBoxCom</class>
        <class>com.blackbox.entities.db.AssemblyPK</class>
        <class>com.blackbox.entities.db.Assembly</class>
       
       

                <properties>
                        <property name="eclipselink.jdbc.password" value="linux4me"/>
                        <property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
                        <property name="eclipselink.jdbc.user" value="root"/>
                        <property name="eclipselink.jdbc.url" value="jdbc:mysql://192.168.0.65:3306/ids2_develop"/>
                        <property name="eclipselink.logging.level" value="FINE"/>
                        <property name="eclipselink.jdbc.cache-statements" value="true"/>
                        <property name="eclipselink.jdbc.native-sql" value="false"/>
                        <property name="eclipselink.cache.type.Vw_Ecu" value="NONE"/>
                        <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                        <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
                        <property name="eclipselink.application-location" value="H:\new_workspace\ids2_databaseBuilder\schema\"/>
                        <property name="eclipselink.create-ddl-jdbc-file-name" value="create_ddl.sql"/>
                        <property name="eclipselink.drop-ddl-jdbc-file-name" value="drop_ddl.sql" />
                       
                </properties>
        </persistence-unit>
</persistence>

Re: Create DB DDL scripts instead of building database

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Roger,

   I am still having trouble recreating your issue.  I am running an Eclipse
Galileo version which contains the eclipselink 1.1.2 library.

   Here is what I did:

1. Create a simple JPA project using Dali with a single Entity
2. Configure it to use EclipseLink as the platform
3. Set the database connection information and ddl generation settings using the
Dali UI
4. Run some simple code that access the entity manager.

I see the ddl generated to my file system and not to my database.

I am attaching my Eclipse project.  Can you see anything different about what
you are doing?  Does this project generate DDL as expected for you?

-Tom

RogerV wrote:

>
>
> tware wrote:
>> Hi Roger,
>>
>>    I just ran a quick test and I seem to get the expected behavior.
>>
>>    How is your persistence unit configured?  Where are the classes?  Where
>> is
>> the persistence.xml?  Is it possible to post the full persistence.xml?  Is
>> your
>> application OSGi?
>>
>> -Tom
>>
>
> Hi Tom
>
> Persistence.xml is attached below. It's in the META-INF directory which is
> in the root of my source directory. It's in the right place as I invalidated
> the xml by removing an end tag and tried to re-run the DDL generation and it
> failed because of the missing end tag so it's reading the right file. The
> entity classes are in sub-directories of the source root. The application is
> not OSGi.
>
> Regards
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" 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_1_0.xsd">
> <persistence-unit name="ids2_develop" transaction-type="RESOURCE_LOCAL">
>
> <description>Eclipse</description>
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> <class>com.blackbox.entities.db.Vw_Ecu</class>
> <class>com.blackbox.entities.db.SwimPart</class>
> <class>com.blackbox.entities.db.SoftwarePK</class>
> <class>com.blackbox.entities.db.Software</class>
> <class>com.blackbox.entities.db.Platform</class>
> <class>com.blackbox.entities.db.PEcuTextPK</class>
> <class>com.blackbox.entities.db.PEcuText</class>
> <class>com.blackbox.entities.db.PEcuAcronymPK</class>
> <class>com.blackbox.entities.db.PEcuAcronym</class>
> <class>com.blackbox.entities.db.PEcu</class>
> <class>com.blackbox.entities.db.PBusPK</class>
> <class>com.blackbox.entities.db.PBus</class>
> <class>com.blackbox.entities.db.HardwarePK</class>
> <class>com.blackbox.entities.db.Hardware</class>
> <class>com.blackbox.entities.db.CusCom</class>
> <class>com.blackbox.entities.db.CCFParameter</class>
> <class>com.blackbox.entities.db.CCFGroup</class>
> <class>com.blackbox.entities.db.Bus</class>
> <class>com.blackbox.entities.db.BBoxCom</class>
> <class>com.blackbox.entities.db.AssemblyPK</class>
> <class>com.blackbox.entities.db.Assembly</class>
>
>
>
> <properties>
> <property name="eclipselink.jdbc.password" value="linux4me"/>
> <property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
> <property name="eclipselink.jdbc.user" value="root"/>
> <property name="eclipselink.jdbc.url"
> value="jdbc:mysql://192.168.0.65:3306/ids2_develop"/>
> <property name="eclipselink.logging.level" value="FINE"/>
> <property name="eclipselink.jdbc.cache-statements" value="true"/>
> <property name="eclipselink.jdbc.native-sql" value="false"/>
> <property name="eclipselink.cache.type.Vw_Ecu" value="NONE"/>
> <property name="eclipselink.ddl-generation"
> value="drop-and-create-tables"/>
> <property name="eclipselink.ddl-generation.output-mode"
> value="sql-script"/>
> <property name="eclipselink.application-location"
> value="H:\new_workspace\ids2_databaseBuilder\schema\"/>
> <property name="eclipselink.create-ddl-jdbc-file-name"
> value="create_ddl.sql"/>
> <property name="eclipselink.drop-ddl-jdbc-file-name" value="drop_ddl.sql"
> />
>
> </properties>
> </persistence-unit>
> </persistence>


_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

TestDDL.jar (9K) Download Attachment

Re: Create DB DDL scripts instead of building database

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


tware wrote:
I am attaching my Eclipse project.  Can you see anything different about what
you are doing?  Does this project generate DDL as expected for you?
Hi Tom

I've had a quick look at your project. I've not used Derby before so I've had to take a flying stab and downloading and installing. Initially, I do not see the ddl files being created. Mind you - if I change the ddl-generation-mode to "database", I don't see the table being created either :( I suspect/hope that this is more to do with my lack of knowledge of Derby than a completely screwed setup my end.


Thanks for your efforts so far, it is appreciated but I'm going to have to play with this outside of the paying job. I'll get back to you when I've got something to report.

Regards
Roger

Re: Create DB DDL scripts instead of building database

by tware :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Roger,

   I would be surprised if the choice of database affects how this works.

   Perhaps the best thing for you to do is to simply change the project to point
to your MySQL DB - it should just be a matter of changing a couple of lines in
the persistence.xml file and updating the project build classpath to use a
different JDBC driver.

-Tom

RogerV wrote:

>
>
> tware wrote:
>>
>> I am attaching my Eclipse project.  Can you see anything different about
>> what
>> you are doing?  Does this project generate DDL as expected for you?
>>
>
> Hi Tom
>
> I've had a quick look at your project. I've not used Derby before so I've
> had to take a flying stab and downloading and installing. Initially, I do
> not see the ddl files being created. Mind you - if I change the
> ddl-generation-mode to "database", I don't see the table being created
> either :( I suspect/hope that this is more to do with my lack of knowledge
> of Derby than a completely screwed setup my end.
>
>
> Thanks for your efforts so far, it is appreciated but I'm going to have to
> play with this outside of the paying job. I'll get back to you when I've got
> something to report.
>
> Regards
> Roger
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users