You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Thorben Wallmeyer <th...@t-online.de> on 2011/02/20 15:48:07 UTC
Automatically creating database schema
Hi everyone,
I'm working with Cayenne and I'm trying to automatically create a schema
when cayenne connects for the first time the the configured databse.
Therefore I've slighty changed my cayenne.xml file, so that it looks like:
<node name="MeTexNode"
datasource="module/storage/MeTexNode.driver.xml"
factory="org.apache.cayenne.conf.DriverDataSourceFactory"
schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
<map-ref name="MeTexORM"/>
</node>
So, I've added the attribute "schema-update-strategy" but nothing
happens - no tables are generated. So what I'm doing wrong? Can you send
me a simple, working example?
Best,
Thorben
Re: Automatically creating database schema
Posted by Andrus Adamchik <an...@objectstyle.org>.
The last time there was a problem with CreateIfNoSchemaStrategy, it was actually strategy being too eager not detecting the existing schema on the following runs:
http://markmail.org/message/7cr4dksbv2foglsm
So the strategy definitely should be invoked on startup. But it can fail for a variety of reasons (such as insufficient DB permissions, or the wrong default schema, etc.) There should be some info in the logs pointing to the cause.
Andrus
On Feb 20, 2011, at 5:38 PM, Christian Grobmeier wrote:
> Actually i have made the same experience. It worked 1 time, then never
> again. But I didn't track it, I used the migration tool in the
> modeller.
>
> On Sun, Feb 20, 2011 at 4:32 PM, Andrus Adamchik <an...@objectstyle.org> wrote:
>> Odd. Configuration seems correct. So what do you see in the logs when Cayenne starts in your application?
>>
>> Andrus
>>
>> On Feb 20, 2011, at 4:48 PM, Thorben Wallmeyer wrote:
>>
>>> Hi everyone,
>>>
>>> I'm working with Cayenne and I'm trying to automatically create a schema when cayenne connects for the first time the the configured databse. Therefore I've slighty changed my cayenne.xml file, so that it looks like:
>>>
>>> <node name="MeTexNode"
>>> datasource="module/storage/MeTexNode.driver.xml"
>>> factory="org.apache.cayenne.conf.DriverDataSourceFactory"
>>> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
>>> <map-ref name="MeTexORM"/>
>>> </node>
>>>
>>>
>>> So, I've added the attribute "schema-update-strategy" but nothing happens - no tables are generated. So what I'm doing wrong? Can you send me a simple, working example?
>>>
>>> Best,
>>>
>>> Thorben
>>
>>
>
>
>
> --
> http://www.grobmeier.de
>
Re: Automatically creating database schema
Posted by Christian Grobmeier <gr...@gmail.com>.
Actually i have made the same experience. It worked 1 time, then never
again. But I didn't track it, I used the migration tool in the
modeller.
On Sun, Feb 20, 2011 at 4:32 PM, Andrus Adamchik <an...@objectstyle.org> wrote:
> Odd. Configuration seems correct. So what do you see in the logs when Cayenne starts in your application?
>
> Andrus
>
> On Feb 20, 2011, at 4:48 PM, Thorben Wallmeyer wrote:
>
>> Hi everyone,
>>
>> I'm working with Cayenne and I'm trying to automatically create a schema when cayenne connects for the first time the the configured databse. Therefore I've slighty changed my cayenne.xml file, so that it looks like:
>>
>> <node name="MeTexNode"
>> datasource="module/storage/MeTexNode.driver.xml"
>> factory="org.apache.cayenne.conf.DriverDataSourceFactory"
>> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
>> <map-ref name="MeTexORM"/>
>> </node>
>>
>>
>> So, I've added the attribute "schema-update-strategy" but nothing happens - no tables are generated. So what I'm doing wrong? Can you send me a simple, working example?
>>
>> Best,
>>
>> Thorben
>
>
--
http://www.grobmeier.de
Re: Automatically creating database schema
Posted by Andrus Adamchik <an...@objectstyle.org>.
Odd. Configuration seems correct. So what do you see in the logs when Cayenne starts in your application?
Andrus
On Feb 20, 2011, at 4:48 PM, Thorben Wallmeyer wrote:
> Hi everyone,
>
> I'm working with Cayenne and I'm trying to automatically create a schema when cayenne connects for the first time the the configured databse. Therefore I've slighty changed my cayenne.xml file, so that it looks like:
>
> <node name="MeTexNode"
> datasource="module/storage/MeTexNode.driver.xml"
> factory="org.apache.cayenne.conf.DriverDataSourceFactory"
> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
> <map-ref name="MeTexORM"/>
> </node>
>
>
> So, I've added the attribute "schema-update-strategy" but nothing happens - no tables are generated. So what I'm doing wrong? Can you send me a simple, working example?
>
> Best,
>
> Thorben