[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Alter table doesn't find table previously created during DDL

According to
http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/package-summary.html
Argument 5 in your datasource definition is setting autocommit to false. Try setting it to true.



Best Regards, Chris

Eric Gulatee wrote:
Michael,

Thank you for the quick response.

Well I do have resource_local transaction type in my persistence.xml. (See below)

The datasource is of type:  org.apache.commons.dbcp.PoolingDataSource

    derbyurl= "jdbc:derby://localhost:1527/digitalart;create=true";
derbydriver = org.apache.derby.jdbc.ClientDriver

Maybe I should not have a pooled connection as a datasource? Would that have any impact?

The SQL generated is good when I execute through an SQL Tool. [I added spring config to generate the create & drop tables]

Thank you for your interest.

<bean id="bds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" ref="derbydriver" />
<property name="url" ref="derbyurl" />
</bean>
<bean id="dsConnectionFactory" class="org.apache.commons.dbcp.DataSourceConnectionFactory">
<constructor-arg>
<ref bean="bds" />
</constructor-arg>
</bean>
<bean id="poolableConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionFactory">
<constructor-arg index="0">
<ref bean="dsConnectionFactory" />
</constructor-arg>
<constructor-arg index="1">
<ref bean="pool" />
</constructor-arg>
<constructor-arg index="2">
<null />
</constructor-arg>
<constructor-arg index="3">
<value>SELECT 1</value>
</constructor-arg>
<constructor-arg index="4">
<value>false</value>
</constructor-arg>
<constructor-arg index="5">
<value>false</value>
</constructor-arg>
</bean>
<bean id="daDataSource" class="org.apache.commons.dbcp.PoolingDataSource"
depends-on="poolableConnectionFactory">
<constructor-arg>
<ref bean="pool" />
</constructor-arg>
</bean></beans>





<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
version="1.0">
<persistence-unit name="DigitalArtJPA"
transaction-type="*RESOURCE_LOCAL*">
<class>da.db.model.ArtCategory</class>
<class>da.db.model.ArtMovement</class>
<class>da.db.model.AuditLog</class>
<class>da.db.model.Buyer</class>
<class>da.db.model.CartItem</class>
<class>da.db.model.Commission</class>
<class>da.db.model.DigitalContent</class>
<class>da.db.model.DigitalItem</class>
<class>da.db.model.DigitalItemTag</class>
<class>da.db.model.Forum</class>
<class>da.db.model.Gallery</class>
<class>da.db.model.GalleryTag</class>
<class>da.db.model.Group</class>
<class>da.db.model.Post</class>
<class>da.db.model.Price</class>
<class>da.db.model.Rating</class>
<class>da.db.model.RatingAggregate</class>
<class>da.db.model.RatingContainer</class>
<class>da.db.model.RememberMe</class>
<class>da.db.model.Seller</class>
<class>da.db.model.User</class>
</persistence-unit>
</persistence>





On Wed, Sep 3, 2008 at 1:34 PM, <MICHAEL.OBRIEN@xxxxxxxxxx <mailto:MICHAEL.OBRIEN@xxxxxxxxxx>> wrote:


Eric,
Hi, The cause should be due to no auto-commit set, or
ddl-generation is running in a JTA transaction.
I noticed that your RESOURCE_LOCAL jdbc settings were not set
in persistence.xml - but they evidently get picked up by the
spring config or in properties set in your app.
Since the spring containter framework is another layer on top
of EclipseLink - i would like to adapt an example scenario for the
combination Tomcat/Derby with/without Spring.
This is an important proof-of-concept app and I will get back
to you on my results and post the example to the following JPA
examples page.
http://wiki.eclipse.org/EclipseLink/Examples/JPA
thank you
/michael


        -----Original Message-----
        *From:* Eric Gulatee [mailto:eric.gulatee@xxxxxxxxx
        <mailto:eric.gulatee@xxxxxxxxx>]
        *Sent:* Wednesday, September 03, 2008 12:34
        *To:* EclipseLink User Discussions
        *Subject:* Re: [eclipselink-users] Alter table doesn't find
        table previously created during DDL

        All,

        I vaguely remember having configured properties for hibernate
        in the EntityManagerFactory. So I moved the settings you
        indicated in the spring config.  Things seem to behave
        slightly differently when I configuring the properties you
        mention to put  in persistence.xml in the spring
        configuration.  (More logging (finest), so the settings take
        only if I put in string config )  However I still have a
        failure on altering tables and the tables DO NOT exist.

I realize the tomcat logs don't show the info stuff I see on
the console.
Anyhow, I will attach my spring config.


Has anyone gotten spring & eclipselink & ddl generation
working together? Any examples or other ideas? Likely
something silly I am not doing.



[EL Info]: 2008.09.03
12:22:20.217--ServerSession(18560421)--Thread(Thread[main,5,main])--EclipseLink,
version: Eclipse Persistence Services - 1.1 (B
ild SNAPSHOT-20080901)
[EL Config]: 2008.09.03
12:22:21.842--ServerSession(18560421)--Connection(5262695)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>DerbyPlatform
user name=> ""
connector=>JNDIConnector datasource name=>null
))
[EL Config]: 2008.09.03
12:22:26.061--ServerSession(18560421)--Connection(4052150)--Thread(Thread[main,5,main])--Connected:
jdbc:derby://localhost:15
7/digitalart;create=true
User: APP
Database: Apache Derby Version: 10.4.1.3
<http://10.4.1.3> - (648739)
Driver: Apache Derby Network Client JDBC Driver Version: 10.4.1.3 <http://10.4.1.3> - (648739)
[EL Config]: 2008.09.03
12:22:26.061--ServerSession(18560421)--Connection(22549381)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>DerbyPlatform
user name=> ""
connector=>JNDIConnector datasource name=>null
))
[EL Config]: 2008.09.03
12:22:26.061--ServerSession(18560421)--Connection(23700826)--Thread(Thread[main,5,main])--Connected:
jdbc:derby://localhost:1
27/digitalart;create=true
User: APP
Database: Apache Derby Version: 10.4.1.3
<http://10.4.1.3> - (648739)
Driver: Apache Derby Network Client JDBC Driver Version: 10.4.1.3 <http://10.4.1.3> - (648739)
[EL Finest]: 2008.09.03
12:22:26.170--ServerSession(18560421)--Thread(Thread[main,5,main])--sequencing
connected, state is Preallocation_Transaction_
oAccessor_State
[EL Finest]: 2008.09.03
12:22:26.170--ServerSession(18560421)--Thread(Thread[main,5,main])--sequence
: preallocation size 50
[EL Finest]: 2008.09.03
12:22:26.170--ServerSession(18560421)--Thread(Thread[main,5,main])--sequence
SEQ_GEN: preallocation size 50
[EL Info]: 2008.09.03
12:22:26.327--ServerSession(18560421)--Thread(Thread[main,5,main])--file:/C:/development/apache-tomcat-6.0.14/webapps/DigitalAr
Web/WEB-INF/lib/da-db-0.0.1-SNAPSHOT.jar-DigitalArtJPA login
successful
[EL Finest]: 2008.09.03
12:22:26.577--ServerSession(18560421)--Thread(Thread[main,5,main])--Execute
query DataModifyQuery()
[EL Finest]: 2008.09.03
12:22:26.592--ServerSession(18560421)--Thread(Thread[main,5,main])--reconnecting
to external connection pool
[EL Fine]: 2008.09.03
12:22:26.592--ServerSession(18560421)--Connection(23310932)--Thread(Thread[main,5,main])--CREATE
TABLE AUDITLOG (ID BIGINT NOT
ULL, USERNAME VARCHAR(255), SESSIONID VARCHAR(255), ACTION
VARCHAR(255), MESSAGE VARCHAR(255), IP VARCHAR(255), USERAGENT
VARCHAR(255), TIMESTAMP TIM
STAMP, PRIMARY KEY (ID))
[EL Finest]: 2008.09.03
12:22:27.030--Thread(Thread[main,5,main])--The table
(AUDITLOG) is created.


        [EL Fine]: 2008.09.03
        12:22:39.733--ServerSession(18560421)--Connection(16233020)--Thread(Thread[main,5,main])--CREATE
        TABLE RATING (ID BIGINT NOT NUL
        L, VALUE INTEGER, CONTAINER_ID BIGINT, USERWHOVOTED_ID BIGINT,
        PRIMARY KEY (ID))
        [EL Finest]: 2008.09.03
        12:22:40.170--Thread(Thread[main,5,main])--The table (RATING)
        is created.
        [EL Finest]: 2008.09.03
        12:22:40.170--ServerSession(18560421)--Thread(Thread[main,5,main])--Execute
        query DataModifyQuery()
        [EL Finest]: 2008.09.03
        12:22:40.170--ServerSession(18560421)--Thread(Thread[main,5,main])--reconnecting
        to external connection pool
        [EL Fine]: 2008.09.03
        12:22:40.170--ServerSession(18560421)--Connection(25626423)--Thread(Thread[main,5,main])--CREATE
        TABLE FORUM (ID BIGINT NOT NULL
        , NAME VARCHAR(255), GALLERY_ID BIGINT, IMAGE_ID BIGINT,
        PRIMARY KEY (ID))
        [EL Finest]: 2008.09.03
        12:22:40.498--Thread(Thread[main,5,main])--The table (FORUM)
        is created.
        [EL Finest]: 2008.09.03
        12:22:40.498--ServerSession(18560421)--Thread(Thread[main,5,main])--Execute
        query DataModifyQuery()
        [EL Finest]: 2008.09.03
        12:22:40.498--ServerSession(18560421)--Thread(Thread[main,5,main])--reconnecting
        to external connection pool
        [EL Fine]: 2008.09.03
        12:22:40.498--ServerSession(18560421)--Connection(26133207)--Thread(Thread[main,5,main])--ALTER
        TABLE GROUPS_GROUPS ADD CONSTRAI
        NT GRUPSGROUPSGroupID FOREIGN KEY (Group_ID) REFERENCES GROUPS
        (ID)
        *[EL Fine]: 2008.09.03
        12:22:40.733--ServerSession(18560421)--Thread(Thread[main,5,main])--VALUES(1)
        [EL Warning]: 2008.09.03
        12:22:40.811--ServerSession(18560421)--Thread(Thread[main,5,main])--Exception
        [EclipseLink-4002] (Eclipse Persistence Service
        s - 1.1 (Build SNAPSHOT-20080901)):
        org.eclipse.persistence.exceptions.DatabaseException
        Internal Exception: java.sql.SQLSyntaxErrorException: 'ALTER
        TABLE' cannot be performed on 'GROUPS_GROUPS' because it does
        not exist.
        Error Code: -1
        Call: ALTER TABLE GROUPS_GROUPS ADD CONSTRAINT
        GRUPSGROUPSGroupID FOREIGN KEY (Group_ID) REFERENCES GROUPS (ID)
        Query: DataModifyQuery()
        [EL Finest]: 2008.09.03
        12:22:40.842--ServerSession(18560421)--Thread(Thread[main,5,main])--Execute
        query DataModifyQuery()
        *[EL Finest]: 2008.09.03
        12:22:40.842--ServerSession(18560421)--Thread(Thread[main,5,main])--reconnecting
        to external connection pool




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


------------------------------------------------------------------------

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