[play-framework] New database module - http://www.playframework.org/modules/db

97 views
Skip to first unread message

Nicolas

unread,
May 16, 2010, 1:59:12 PM5/16/10
to play-framework
Hi all,

I have just released a new module that I think is really useful
(actually I hesitated to provide the functionality per default in
Play! so you don't have to enable the module):

http://www.playframework.org/modules/db

In short:

* play db:export --output=bla.sql will generate a sql script to create
your database based on your actual object model

* play db:import will import your database table into your domain
model (so it generates java files that extends JPASupport)

It is necessary to enable the module and to configure your database
connection in the application.conf file. I think that is pretty simple
and that is why it is Play! compatible.


The next step for this module will be to generate diff between the
database and the object model automatically.

The obvious next step will then be to merge this module and the DB
migrate module.

In term of POJO generation, it would also be nice if this module could
generates the CRUD controller if asked for. Another feature would be
to generate the object model as scala objects.

Under the hood the module uses a modified hibernate tools (so it works
with Hibernate 3.5). Hibernate tools uses freemarker to generate
files, so I had to modified those as well. I will publish all the
sources shortly.

As usual, please report all the bugs on http://github.com/pepite/play--database
. Contribution and help are more than welcome :)

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Roch Delsalle

unread,
May 16, 2010, 3:15:14 PM5/16/10
to play-fr...@googlegroups.com
Great module thank you very much
--
Roch Delsalle

Daniel Guryca

unread,
May 16, 2010, 3:36:58 PM5/16/10
to play-fr...@googlegroups.com
Hi,

Yes very useful and mainly it will be very useful for production mode after:

"The next step for this module will be to generate diff between the
database and the object model automatically."

Great stuff !

Daniel

si

unread,
May 16, 2010, 4:24:50 PM5/16/10
to play-framework
Perfect!
> As usual, please report all the bugs onhttp://github.com/pepite/play--database

曹江华

unread,
May 16, 2010, 8:44:16 PM5/16/10
to play-fr...@googlegroups.com
multi datasource can supported?
--
http://www.caojianghua.com

Archer Yongjian Liu

unread,
May 16, 2010, 11:49:46 PM5/16/10
to play-fr...@googlegroups.com
After I typing this command and run :

play db:export myapplication --output=c:\myfile.ddl

I can't find the myfile.ddl in c:\ driver
--
Thank you.

Nicolas Leroux

unread,
May 17, 2010, 1:27:50 AM5/17/10
to play-fr...@googlegroups.com
With play! < 1.0.2.1 the -- command won't work. You need to use the play! nightly if you want to have the --output option (as mentioned in the doc), due to a scripting API change.

However, doing:

 play db:export myapp 

will work just fine (you need to configure your application.conf, especially the jpa.dialect option).

Nicolas

Nicolas Leroux

unread,
May 17, 2010, 1:29:35 AM5/17/10
to play-fr...@googlegroups.com
What do you mean?

You have to specify your datasource in the application.conf and then run:

play db:export myapp

If you want to support multi datasource then change again your application.conf and rerun

play db:export myapp

The module does not support multiple datasource at the same time.

Nicolas

grandfatha

unread,
May 17, 2010, 2:12:55 AM5/17/10
to play-framework
This is absolutely amazing. Thank you for your great work.

On 17 Mai, 07:29, Nicolas Leroux <nico...@lunatech.com> wrote:
> What do you mean?
>
> You have to specify your datasource in the application.conf and then run:
>
> play db:export myapp
>
> If you want to support multi datasource then change again your application.conf and rerun
>
> play db:export myapp
>
> The module does not support multiple datasource at the same time.
>
> Nicolas
> On 17 mei 2010, at 02:44, 曹江华 wrote:
>
>
>
>
>
> > multi datasource can supported?
>

Nicolas Leroux

unread,
May 19, 2010, 5:18:09 AM5/19/10
to play-fr...@googlegroups.com
Hi,


On 19 mei 2010, at 01:57, paperin0 wrote:

> Could you explain how to use db:import in order to import an existing
> database? Where does the current DB information need to be configured?

First, install the module:

play install db

You need to configure the file conf/application.conf

Just fill in the right information in the db. section


and then run play db:import

You should then have all the java files in app/models/

Nicolas

>
> Thanks this looks great!
>> As usual, please report all the bugs onhttp://github.com/pepite/play--database

paperin0

unread,
May 18, 2010, 7:57:14 PM5/18/10
to play-framework
Could you explain how to use db:import in order to import an existing
database? Where does the current DB information need to be configured?

Thanks this looks great!

On May 16, 10:59 am, Nicolas <leroux.nico...@gmail.com> wrote:
> As usual, please report all the bugs onhttp://github.com/pepite/play--database

paperin0

unread,
May 25, 2010, 3:13:01 PM5/25/10
to play-framework
Worked wonderfully. Thank you for the response. I'd love to see this
working with the CRUD module :).

> >> generates theCRUDcontroller if asked for. Another feature would be

Nicolas Leroux

unread,
May 26, 2010, 6:59:48 AM5/26/10
to play-fr...@googlegroups.com
Yes, that is on my todo list...

2010/5/25 paperin0 <bobbyd...@gmail.com>:

--
Nicolas Leroux

Reply all
Reply to author
Forward
0 new messages