cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: Database generation SQL script creation in background
Date Tue, 14 Aug 2012 14:12:23 GMT
If you want to do it from java code, this is how I used to set up test
databases in Cayenne 1.1.  It's probably slightly different now.

    public static void createSchemaForObjEntityName(Configuration
configuration, String objEntityName) throws Exception
    {
        DataNode dataNode =
getDataNodeForConfigurationAndObjEntityName(configuration,
objEntityName);

		DataSource dataSource = dataNode.getDataSource();
        DbAdapter dbAdapter = dataNode.getAdapter();
        Iterator dataMapIterator = dataNode.getDataMaps().iterator();
        while (dataMapIterator.hasNext())
        {
            DataMap dataMap = (DataMap) dataMapIterator.next();

            DbGenerator dbGenerator = new DbGenerator(dbAdapter, dataMap);
            boolean notCleanState = true;
//            if (CayenneTestDatabaseFramework.isHsqldbDriver())
//            {
//                // assume we're using the in-memory version
//                notCleanState = false;
//            }
            dbGenerator.setShouldDropTables(notCleanState);
            dbGenerator.setShouldDropPKSupport(notCleanState);
            dbGenerator.setShouldCreatePKSupport(true);
            dbGenerator.setShouldCreateTables(true);
            dbGenerator.setShouldCreateFKConstraints(false);
            dbGenerator.runGenerator(dataSource);
        }
    }

On Tue, Aug 14, 2012 at 1:57 AM, Martin Weber <wwwebi@hispeed.ch> wrote:
> Hi John,
>
> main purpose is to make a fresh database installation during an automated
> nightly build. After the build I have scripts which create databases and
> then load data and run tests. The creation is only possible if I don't need
> a GUI. But I think the cdbgen ant task could be what I'm looking at.
>
> Cheers,
> Martin
>
>
> On 14.08.2012 05:38, John Huss wrote:
>>
>> For what purpose?  What is your broader goal?  There are a few different
>> ways of creating the scheme using Cayenne.
>>
>> John
>>
>> On Monday, August 13, 2012, Martin Weber wrote:
>>
>>> Hi,
>>>
>>> Is there a solution to create the database generation SQL script without
>>> starting the GUI modeler ? I would like to create the db generation
>>> script
>>> within an ant task or a shell/batch script.
>>>
>>> Thanks,
>>> Martin
>>>
>>
>

Mime
View raw message