You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Dave Merrin <dm...@ipasystems.co.uk> on 2007/11/15 15:05:05 UTC

Reengineer Database Schema ant task

Hi,

is there an ant task to reengineer the database as you can with Cayenne 
Modeler?

Cheers,

Dave

Re: Reengineer Database Schema ant task

Posted by Dave Merrin <dm...@ipasystems.co.uk>.
Cheers Andrus. I'm just looking at the code now. Will give it a try.

Dave

Andrus Adamchik wrote:
> Dave,
>
> You can use DbLoader class to reengineer DB from your code or build an 
> Ant task on top of it.
>
> In fact if you map the entities as generic classes during 
> reengineering, you can use the generated DataMap in the application 
> right away, without a restart. I've done it on one project. IMO such 
> dynamic ORM is pretty cool.
>
> Andrus
>
>
> On Nov 15, 2007, at 10:52 AM, Dave Merrin wrote:
>
>> Hi Kevin,
>>
>> can I make direct use of a function in the Modeler jar to instantiate 
>> a generate from my own app?
>>
>> It would be good in Cayenne but I think it will be a long time before 
>> I move to version 3. I don't want somebody to do all the work and it 
>> never gets used.
>>
>> Cheers,
>>
>> Dave
>>
>> Kevin Menard wrote:
>>> Hi Dave,
>>>
>>> There is not currently any ant task for that.  The expectation has 
>>> been that
>>> you would generate the datamap once from the modeler, and then use 
>>> the cgen
>>> ant task to generate the classes.  Now that Tore has added code in the
>>> modeler for merging changes between the DB and the datamap, it may be
>>> worthwhile to add some sort of ant task for that.
>>>
>>> If it is something you'd like to see in 3.0, please file a JIRA and 
>>> it'll
>>> get reviewed.
>>>
>>> On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> is there an ant task to reengineer the database as you can with 
>>>> Cayenne
>>>> Modeler?
>>>>
>>>> Cheers,
>>>>
>>>> Dave
>>>>
>>>
>>>
>>
>>
>
>


Re: Reengineer Database Schema ant task

Posted by Andrus Adamchik <an...@objectstyle.org>.
Dave,

You can use DbLoader class to reengineer DB from your code or build  
an Ant task on top of it.

In fact if you map the entities as generic classes during  
reengineering, you can use the generated DataMap in the application  
right away, without a restart. I've done it on one project. IMO such  
dynamic ORM is pretty cool.

Andrus


On Nov 15, 2007, at 10:52 AM, Dave Merrin wrote:

> Hi Kevin,
>
> can I make direct use of a function in the Modeler jar to  
> instantiate a generate from my own app?
>
> It would be good in Cayenne but I think it will be a long time  
> before I move to version 3. I don't want somebody to do all the  
> work and it never gets used.
>
> Cheers,
>
> Dave
>
> Kevin Menard wrote:
>> Hi Dave,
>>
>> There is not currently any ant task for that.  The expectation has  
>> been that
>> you would generate the datamap once from the modeler, and then use  
>> the cgen
>> ant task to generate the classes.  Now that Tore has added code in  
>> the
>> modeler for merging changes between the DB and the datamap, it may be
>> worthwhile to add some sort of ant task for that.
>>
>> If it is something you'd like to see in 3.0, please file a JIRA  
>> and it'll
>> get reviewed.
>>
>> On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
>>
>>
>>> Hi,
>>>
>>> is there an ant task to reengineer the database as you can with  
>>> Cayenne
>>> Modeler?
>>>
>>> Cheers,
>>>
>>> Dave
>>>
>>
>>
>
>


Re: Reengineer Database Schema ant task

Posted by Mike Kienenberger <mk...@gmail.com>.
For what it's worth, it's simple enough to call the schema generator
just by adding the modeler jar file to the classpath, so I'd expect
the reengineer task to be equally easy:

            boolean notCleanState = true;

            DbGenerator dbGenerator = new DbGenerator(dbAdapter, dataMap);

            dbGenerator.setShouldDropTables(notCleanState);
            dbGenerator.setShouldDropPKSupport(notCleanState);
            dbGenerator.setShouldCreatePKSupport(true);
            dbGenerator.setShouldCreateTables(true);

            dbGenerator.setShouldCreateFKConstraints(false);
            dbGenerator.runGenerator(dataSource);



On 11/15/07, Kevin Menard <km...@servprise.com> wrote:
> Off-hand, I can't say for certain.  But, I had originally ported cgen (or
> maybe cdbgen, I don't recall), based on the code in the modeler and it was
> quite straightforward.  Most of the modeler code is pretty well segmented
> and you should be able to make calls into it by just adding the modeler JAR
> to your classpath.
>
> You may find it beneficial to yank it out into a utility class, though.  If
> you do that and attach it to the JIRA, that's most of the hardwork in making
> it an ant task anyway.
>
> --
> Kevin
>
>
> On 11/15/07 10:52 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
>
> > Hi Kevin,
> >
> > can I make direct use of a function in the Modeler jar to instantiate a
> > generate from my own app?
> >
> > It would be good in Cayenne but I think it will be a long time before I
> > move to version 3. I don't want somebody to do all the work and it never
> > gets used.
> >
> > Cheers,
> >
> > Dave
> >
> > Kevin Menard wrote:
> >> Hi Dave,
> >>
> >> There is not currently any ant task for that.  The expectation has been that
> >> you would generate the datamap once from the modeler, and then use the cgen
> >> ant task to generate the classes.  Now that Tore has added code in the
> >> modeler for merging changes between the DB and the datamap, it may be
> >> worthwhile to add some sort of ant task for that.
> >>
> >> If it is something you'd like to see in 3.0, please file a JIRA and it'll
> >> get reviewed.
> >>
> >>
> >> On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
> >>
> >>
> >>> Hi,
> >>>
> >>> is there an ant task to reengineer the database as you can with Cayenne
> >>> Modeler?
> >>>
> >>> Cheers,
> >>>
> >>> Dave
> >>>
> >>
> >>
> >
>
> --
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for network equipment
> www.servprise.com              +1 508.892.3823 x308
>
>

Re: Reengineer Database Schema ant task

Posted by Kevin Menard <km...@servprise.com>.
Off-hand, I can't say for certain.  But, I had originally ported cgen (or
maybe cdbgen, I don't recall), based on the code in the modeler and it was
quite straightforward.  Most of the modeler code is pretty well segmented
and you should be able to make calls into it by just adding the modeler JAR
to your classpath.

You may find it beneficial to yank it out into a utility class, though.  If
you do that and attach it to the JIRA, that's most of the hardwork in making
it an ant task anyway.

-- 
Kevin


On 11/15/07 10:52 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:

> Hi Kevin,
> 
> can I make direct use of a function in the Modeler jar to instantiate a
> generate from my own app?
> 
> It would be good in Cayenne but I think it will be a long time before I
> move to version 3. I don't want somebody to do all the work and it never
> gets used.
> 
> Cheers,
> 
> Dave
> 
> Kevin Menard wrote:
>> Hi Dave,
>> 
>> There is not currently any ant task for that.  The expectation has been that
>> you would generate the datamap once from the modeler, and then use the cgen
>> ant task to generate the classes.  Now that Tore has added code in the
>> modeler for merging changes between the DB and the datamap, it may be
>> worthwhile to add some sort of ant task for that.
>> 
>> If it is something you'd like to see in 3.0, please file a JIRA and it'll
>> get reviewed. 
>> 
>> 
>> On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
>> 
>>   
>>> Hi,
>>> 
>>> is there an ant task to reengineer the database as you can with Cayenne
>>> Modeler?
>>> 
>>> Cheers,
>>> 
>>> Dave
>>>     
>> 
>>   
> 

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308


Re: Reengineer Database Schema ant task

Posted by Dave Merrin <dm...@ipasystems.co.uk>.
Hi Kevin,

can I make direct use of a function in the Modeler jar to instantiate a 
generate from my own app?

It would be good in Cayenne but I think it will be a long time before I 
move to version 3. I don't want somebody to do all the work and it never 
gets used.

Cheers,

Dave

Kevin Menard wrote:
> Hi Dave,
>
> There is not currently any ant task for that.  The expectation has been that
> you would generate the datamap once from the modeler, and then use the cgen
> ant task to generate the classes.  Now that Tore has added code in the
> modeler for merging changes between the DB and the datamap, it may be
> worthwhile to add some sort of ant task for that.
>
> If it is something you'd like to see in 3.0, please file a JIRA and it'll
> get reviewed. 
>
>
> On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:
>
>   
>> Hi,
>>
>> is there an ant task to reengineer the database as you can with Cayenne
>> Modeler?
>>
>> Cheers,
>>
>> Dave
>>     
>
>   


Re: Reengineer Database Schema ant task

Posted by Kevin Menard <km...@servprise.com>.
Hi Dave,

There is not currently any ant task for that.  The expectation has been that
you would generate the datamap once from the modeler, and then use the cgen
ant task to generate the classes.  Now that Tore has added code in the
modeler for merging changes between the DB and the datamap, it may be
worthwhile to add some sort of ant task for that.

If it is something you'd like to see in 3.0, please file a JIRA and it'll
get reviewed. 


On 11/15/07 9:05 AM, "Dave Merrin" <dm...@ipasystems.co.uk> wrote:

> Hi,
> 
> is there an ant task to reengineer the database as you can with Cayenne
> Modeler?
> 
> Cheers,
> 
> Dave

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308