[Lift] Re: jpa, emf Model and unit tests

2009-04-28 Thread TSP
But you don't want the Session in the domain model I thought. Anyway, after a few hours digging around looking at how other people do this stuff with respect to DDD in particular, it looks like I am asking the wrong question to a certain extent. The way it is done in the DDD site sample app

[Lift] Re: jpa, emf Model and unit tests

2009-04-28 Thread TSP
Hi Derek, This is proving a useful debate for me since it has helped clarify my issues. As far as I can see the conventional method of using JPA is, within a single session to use some initial query process to obtain one or more entities. All subsequent operations within that session must be

[Lift] Re: jpa, emf Model and unit tests

2009-04-28 Thread Derek Chen-Becker
OK, the DDD approach makes more sense. Having a layer of repository DAO interfaces that can be implemented by concrete provider classes is a common way of separating this out, and is much cleaner than having any DAO functionality on your entities proper. Just thinking off the top of my head, you

[Lift] Re: jpa, emf Model and unit tests

2009-04-27 Thread Viktor Klang
Why don't collection mappings work? Also, from personal experience, mixing persistence-logic in domain objects does make you feel somewhat naughty. On Mon, Apr 27, 2009 at 9:15 PM, Tim P tim.pig...@optrak.co.uk wrote: Hi I'm looking for some guidance here and I don't think this is addressed

[Lift] Re: jpa, emf Model and unit tests

2009-04-27 Thread Derek Chen-Becker
I may be misunderstanding this, but if you just do bidirectional mappings in JPA then the DB query is generally efficient and transparent. Could you post a little snippet showing what you're trying to do? Derek On Mon, Apr 27, 2009 at 2:44 PM, TSP tim.pig...@optrak.co.uk wrote: Viktor, It's

[Lift] Re: jpa, emf Model and unit tests

2009-04-27 Thread TSP
There are two questions here. I don't really want to get bogged down in bidrectional mappings I was rather hoping for suggestions on how my domain objects might simply get at the right Model transparently from both application and junit (in Grails it was done with Spring injection - here perhaps

[Lift] Re: jpa, emf Model and unit tests

2009-04-27 Thread Derek Chen-Becker
OK, for one, the bidirectional mapping adds no cost in terms of DB access other than the time it takes you to write it. Collections are lazily loaded, so unless your code *retrieves* City.addresses, the database never gets hit. JPA is really not designed with the concept of entities having access

[Lift] Re: jpa, emf Model and unit tests

2009-04-27 Thread Viktor Klang
Also, if you use Hibernate, you can use: *Session.createFilter*(city.getAddresses(), where this.name like 'S%').list(); On Tue, Apr 28, 2009 at 5:31 AM, Derek Chen-Becker dchenbec...@gmail.comwrote: OK, for one, the bidirectional mapping adds no cost in terms of DB access other than the time