You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by beyondjusitn <be...@gmail.com> on 2008/04/01 06:32:06 UTC
Re: How could I create dynamic table through jpa?
Thanks Mike, I'll give it a try. ^_^
Michael Dick wrote:
>
> I suppose you could use a native query to create tables.
>
> Something like this should work :
> EntityManager em = emf.createEntityManager();
>
> em.getTransaction().begin();
>
> em.createNativeQuery("CREATE TABLE MYTABLE (ID INTEGER, ...)")
> .executeUpdate();
>
> em.getTransaction().commit();
>
> em.close();
>
> You need the appropriate authority on the database of course, but I think
> the example above will work.
>
> -Mike
>
> On Sat, Mar 29, 2008 at 7:55 AM, beyondjusitn <be...@gmail.com>
> wrote:
>
>>
>> Hi,
>>
>> I'm trying to create table dynamically in my program. I'm using NetBean
>> 6.0.1 and my sql 5.0.45. What I did is as follows.
>>
>> 1) I've tested that if I use SELECT syntax, the remote ejb method
>> returned
>> the right result to me.
>> 2) If i change the query from " select * from table" to "create table"
>> then
>> there is error.
>> at
>> com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotReadInfo(
>> ORBUtilSystemException.java:9798)
>> at
>> com.sun.corba.ee.impl.servicecontext.UEInfoServiceContextImpl.<init>(
>> UEInfoServiceContextImpl.java:70)
>> at
>> com.sun.corba.ee.spi.servicecontext.ServiceContextDefaults$5.create(
>> ServiceContextDefaults.java:200)
>> at
>> com.sun.corba.ee.impl.servicecontext.ServiceContextsImpl.unmarshal(
>> ServiceContextsImpl.java:276)
>> at
>> com.sun.corba.ee.impl.servicecontext.ServiceContextsImpl.get(
>> ServiceContextsImpl.java:459)
>> at
>>
>> com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse
>> (CorbaClientRequestDispatcherImpl.java:511)
>> at
>>
>> com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete
>> (CorbaClientRequestDispatcherImpl.java:363)
>> at
>> com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(
>> CorbaClientDelegateImpl.java:219)
>> at
>>
>> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke
>> (StubInvocationHandlerImpl.java:192)
>> at
>> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(
>> StubInvocationHandlerImpl.java:152)
>> at
>> com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(
>> BCELStubBase.java:225)
>> at
>>
>> ejb.__InsPerfRemote_Remote_DynamicStub.testAddTable(ejb/__InsPerfRemote_Remote_DynamicStub.java)
>> ... 2 more
>> 3) my persistence.xml is
>> <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="testUnite" transaction-type="JTA">
>> <provider>oracle.toplink.essentials.PersistenceProvider</provider>
>> <jta-data-source>mySqlJNDI</jta-data-source>
>> <properties>
>> <property name="toplink.ddl-generation"
>> value="drop-and-create-tables"/>
>> </properties>
>> </persistence-unit>
>> </persistence>
>>
>> Could anyone tell me where I am wrong, or give me an tutorial on how to
>> create tables through jpa.
>>
>> Thanks a lot!
>>
>> -----
>> --
>> Best Wishes!
>> Justin Tsao
>> --
>> View this message in context:
>> http://www.nabble.com/How-could-I-create-dynamic-table-through-jpa--tp16369718p16369718.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>>
>
>
-----
--
Best Wishes!
Justin Tsao
--
View this message in context: http://www.nabble.com/How-could-I-create-dynamic-table-through-jpa--tp16369718p16411896.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.