dev@glassfish.java.net

Re: Unable to drop tables at deployment/undeployment time

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Wed, 06 Feb 2008 10:17:07 -0800

Hi Sekhar,

This might help you in regards to TopLink defaults:
http://docs.sun.com/app/docs/doc/819-3672/gescc?l=en&a=view&q=sequence

-marina

Sekhar Vajjhala wrote:
> Hi Marina & Jathir,
>
> Comments to both of your response inline.
>
> I do restart the database. The steps I usually do are:
> asadmin start-database
> asadmin start-domain
> deploy <ear-file>
>
> Marina, regarding ignoring the WARNING message.
> I could do that but I would like to understand if this is a
> migration issue ( Hibernate -> Toplink ) and if so, capture
> it as such. And it looks like one to me.
> I came across this issue while migrating a JBoss
> sample to GF and I switched from Hibernate to TopLink.
>
> It looks like the SEQUECE table is being generated because
> of @GeneratedValue @Id on a field in an entity class. I am using
> Toplink.
>
> @Entity
> public class Foo {
>
> private long id;
> .... @Id @GeneratedValue
> public long getId() { return id };
> // setter omitted
> ....
> }
>
> So @GeneratedValue.strategy() defaults to AUTO, which leaves the mapping
> of the field to the JPA provider. In my case it is Toplink.
> I don't recall seeing this behavior when deploying the sample on
> JBoss 4.2.2 using Hibernate. But then I was not looking for this
> explicitly either. I will get around to double checking that.
> In the meantime, does anyone have any input on the strategy
> used by Hibernate for @GeneratedValue.AUTO ?
>
> Thanks,
> Sekhar
>
>
> jothir ganesan - Sun Microsystems - Bangalore India wrote:
>
>> Hi Sekhar,
>>
>> Can you restart the database and then try to deploy?
>>
>> Thanks
>> Jothir
>>
>> Sekhar Vajjhala wrote:
>>
>>> I am trying to deploy an ear file with the following persistence.xml
>>> to drop and create tables at deployment time on GF 9.1 .
>>>
>>> <persistence>
>>> <persistence-unit name="helloworld">
>>> <properties>
>>> <!--Use the java2db feature -->
>>> <property name="toplink.ddl-generation"
>>> value="drop-and-create-tables"/>
>>> </properties>
>>> </persistence-unit>
>>> </persistence>
>>>
>>> The deployment succeeds but I keep getting the following error:
>>>
>>> JDO76614: Deployment encountered SQL Exceptions:
>>> JDO76609: Got SQLException executing statement "CREATE TABLE
>>> SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT
>>> DECIMAL, PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View
>>> 'SEQUENCE' already exists in Schema 'APP'.
>>>
>>> I have also tried the options to asadmin commands
>>> (to override persistence.xml settings)
>>>
>>> undeploy --droptables==true javaeecomponent
>>> or deploy --dropandcreatetables=true <ear-file>
>>>
>>> but I still get the same exception.
>>>
>>> Suggestions ?
>>>
>>> Thanks,
>>> Sekhar
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>