Play + Scalikejdbc +Postgres


Create a new project from scala seed

sbt new playframework/play-scala-seed.g8

1_seed

Import in IntelliJ IDEA.

Open build.sbt and add:

2_application.conf

Open conf/application.conf

Add as following

3_conf

http://scalikejdbc.org/documentation/playframework-support.html

In plugin.sbt add the following

3_reverse_plugin

And enable the reverse plugin at build.sbt

enablePlugins(ScalikejdbcPlugin)

Create a configuration file in project/scalikejdbc.properties

5_scalikejdbc

This configuration will allow us to create a model from existing db tables. Next step is to go a terminal (In IntelliJ IDEA there is a Terminal access on the botton, next to sbt terminal) in the root directory of your project and execute:

sbt "scalikejdbcGen messages Messages"

If all configurations are correct you will get a result like this:

6_model_creation_scalikejdbcGen

 

After that a models package containing a Messages case class with the implementation of methods for CRUD are created in our project.

However the automation provided is awesome for this type of examples, since our table has a serial id we need to change the signature of our case class to exclude the id and to implement the date automatically (not provided by)

 

http://scalikejdbc.org/documentation/setup.html

Etiquetas: , , , ,

About martincx

| Trabajo con Computadores (Y personas) | Ancient Alien Theorist (?)| Madman | Internet | Libros | Con una lista interminable de cosas por hacer, pero completada de a poco. Follow me on twitter.com @martincx

Este blog se enriquece con los comentarios, deja acá tu impresión.

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: