DATABASE revisit

Studied many courses from those 3NF to uncertainty database on database, I am totally not hands on in this field. I wrote less than 10 sqls last year that require JOIN or so.

For my not-much-progress master project I will need to work harder on this I believe. From indexing, clustering, storing index etc. afterall the app is to manage data.

Something on this weekend:

1) Setting connection with Postgresql x Hibernate x Play is quicker than expected . Sometimes these kind of setup can ruin your week.

so basically

  1. set deps in build.scala postgres driver & hibernate

    “org.hibernate” % “hibernate-entitymanager” % “3.6.9.Final”, “postgresql” % “postgresql” % “9.1-901.jdbc4”

  2. add into app.conf db.default.url=”postgres://admin:password@localhost/dbname”
  3. For jpa add persistence.xml into conf/META-INF define the defaultPersistenceUnit 1.
  4. For jpa add into app.conf jpa.default=defaultPersistenceUnit

2) Meanwhile, Hibernate & jpa is more complicated than I thought.

Managing those many-to-one entity relationships is definitely no easy. Especially on older version (3.x & jpa 1), there were Many xmls & duplicated boilerplate to define them. The documentation is also sometimes hard to find.

To say that again, It is never a must for people switching from relational to ORM or noSql.

For my master project I drilled down Hibernate Search a bit previously. I should revise those database stuff again..

3) this situation comes again:

so I forget how to draw er diagram. Then I google to see what syntax to follow. After all I wonder

should I draw a domain model or simply an er diagram…. this time the context being you are using hibernate.

4) In my both my work & my hobby project I need to prepare some static data for testing.

Doing that with transactional jpa is a bit problematic as someone said.

The “Fixture” functions in play 1.x has been missing in 2.0. It was using YAML to load data via java api , and this seems to be nicely doable with some other tools now anyway (Sneakyaml +Dbunit)

Dbunit seems worth a try. Extension of JUnit allow you to import/export data from/to your database.

Applying in company, this rare case I feel using XML for this quite comfortable.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s