Domanda

I am currently working on a play app to be the backend API for a mobile app I'm developing.

Until now, I had set jpa.ddl to update and everything has been working fine. When I added a new field to one of my models, it would change the database for me.

However, I am getting ready for production and everything I have read, including the play documentation says to turn that feature off and to instead use evolutions. However, as I am writing my 1.sql file, I am running into several issues:

  • I have arrays as part of my model and I am unsure as to how they are represented in the database
  • Parts of the model are instances of other models and I am unsure as to how objects are represented in the database

Until now, I didn't have to worry about how the database was actually constructed because Play/JPA/Hibernate provided a level of abstraction. But now that it seems I need to manually create the tables myself, I can't find any documentation for the right way to do this.

Do I need to manually write the SQL to create the tables for my models and if so, how do I represent these in the database?

EDIT: I am using play 1.2.4

È stato utile?

Soluzione

Yes to do evolution you have to know how to convert objects to tables. This will also help you understand how JPA works.

To do so you can look into your database to see how the automatic ddl update creates your database. There is also some doc on the net on this. For exemple here : http://en.wikibooks.org/wiki/Java_Persistence. Chapter 4 contains diagrams to explain this.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top