[Lift] Re: scalajpa - wrong database?
I tried to construct a test case and the problem seems to have mysteriously disappeared. Possibly something to do with clean builds. Sorry to cry wolf. Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: [scala] JPA question
Derek Would you distinguish between what is achievable in a specific ORM such as Hibernate from JPA in this statement or would you think it applies to all. I've got to go with hibernate in any case because of widespread use of UserTypes. Unlike Greg, in my case I can hand-craft all my hibernate xml files if I need. Tim On Jun 23, 1:46 am, Derek Chen-Becker dchenbec...@gmail.com wrote: For sufficiently complex relationships, JPA is not a good fit. Beyond a certain point it's usually simpler to roll your own. I think that this is somewhat of a failing of the model, but it's not a simple problem to solve in the generic case. Derek On Mon, Jun 22, 2009 at 6:45 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: Ah, sorry, I lost track of the thread. On Mon, Jun 22, 2009 at 4:55 PM, Meredith Gregory lgreg.mered...@gmail.com wrote: Derek, You are correct and i noted and reported this on Scala on Friday. However, if you have a chain of the form AbstractClass - Class -contains- AbstractClass -Class -contains- ... The @MappedSuperclass solution fails at level 2. Best wishes, --greg On Mon, Jun 22, 2009 at 3:52 PM, Derek Chen-Becker dchenbec...@gmail.com wrote: Something I just want to throw out into the discussion: Since you're using table-per-class, having a @Table annotation on AbstractContainer doesn't do anything since abstract classes can't have instances. Tables are only generated for abstract classes if you're using a JOINED inheritance strategy. You might want to look at using the MappedSuperclass annotation for the abstract base class instead. If I change the AbstractContainer def to: @MappedSuperclass public abstract class AbstractContainer implements java.io.Serializable { and then modify MySampleFuContainer to: public class MySampleFuContainer extends AbstractContainer { then I seem to get the proper schema: create table lingo_production.MySampleFuContainer_table ( id varchar(255) not null, uuid varchar(255), mysamplingmumble__idSuper varchar(255), primary key (id), unique (uuid) ); Having said that, I think that the behavior you're currently seeing appears to be a bug. Derek On Mon, Jun 22, 2009 at 3:43 PM, Meredith Gregory lgreg.mered...@gmail.com wrote: Kris, Herehttp://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate/is a link to the self-contained example that now uses just Java. i included the target dir in the repo to speed up investigation, but you can just blow that away and build from scratch. The example is currently written to Java1.6, but also exhibits the same behavior under Java1.5. To run the example svn co http://svn.biosimilarity.com/src/open/codesamples/trunk/hibernate ... env PATH=path-to-java1.6:$PATH JAVA_HOME=path-to-java1.6 mvn clean compile process-classes If you switch comment and decl at line 22 in src/main/java/maxb/hbex2/MySampleFuContainer.java then you see the error. The schema goes from create table lingo_production.MySampleFuContainer_table ( id_AbstractContainer varchar(255) not null, varchar(255) not null, uuid varchar(255), mysamplingmumble__idSuper varchar(255), primary key (id), unique (uuid) ); to create table lingo_production.MySampleFuContainer_table ( id_AbstractContainer varchar(255) not null, id varchar(255), mysamplingmumble_ tinyblob, uuid varchar(255), primary key (id_AbstractContainer), unique (id_AbstractContainer) ); Best wishes, --greg On Mon, Jun 22, 2009 at 1:38 PM, Meredith Gregory lgreg.mered...@gmail.com wrote: Kris, Thanks for the suggestion. i've now got a tiny little example that compiles on its own that illustrates the problem. Changing the inheritance strategy to JOINED makes no difference. Hibernate still does the wrong thing. Best wishes, --greg On Mon, Jun 22, 2009 at 8:55 AM, Kris Nuttycombe kris.nuttyco...@gmail.com wrote: This may be off the mark, but I'm wondering if the reason that you're having difficulty with the parallel inheritance hierarchy problem is not your use of TABLE_PER_CLASS inheritance. In my application, I have a similar construct, but I am using JOINED_TABLE inheritance. This allows for a normal foreign key relationship to be created in the database between C2_table and the base table for CThing, with the result that Hibernate will generate the query for CThing member as a union. Using table per class inheritance, I would expect Hibernate to need to synthesize an additional dtype field in C2_table along with the key column in order to enforce the uniqueness of the keys to the joined entities, and I don't believe that it does this. I'm not sure how the fact that the code is generated is particularly relevant;
[Lift] Re: scalajpa - while accessing two distincts databases, the second access is made with a connection to the first database
In my own defense ... failed to realize the problem that would arise from defining the EM factory as a singleton Are you being honest here Derek? Was not the real problem that you failed to truly embrace the shape of the paradoxical combinator? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Logging question
Does the lift logging framework support the classed based loggers that are the normal use pattern: Logger logger = Logger.getLogger(com.foo); and the class is automatically attached to the message. If so how do you call it - with a direct java import or is there something more lift-esque Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift documentation -- Attention newcomers (and everyone else)!
Examples, examples, examples, including scala. The scala-lang site is a bit daunting. I think you'll get more traction on Lift if you help people to get to grips with scala as well as lift. I have no idea whether I'm a typical newcomer, but I have come from Java (previously other things going back to pascal) but as I'm not from a computer science background have no real knowledge or understanding of functional programming. Lots of scala stuff is pretty strange territory. People want a tool like Lift to do stuff quickly and easily. I'm constantly having to reference my set of 4 books (3 of which are pre-publication) just to get the scala way of doing something simple. I think people should be strongly encouraged to things they did to solve particular problems - not so much as an example of best practice but more I did it like this, is there a better way? I personally find the discussions like the one on the scala user mailing list on treatment of enumerations in java vs scala useful and interesting but they too often reference what to me are still esoteric parts of the language that I have yet to master. So wiki pages where you could have similar threads but with a culture of illustrating every comment with a real example would be a great way to learn. I suspect most people from my type of background are starting out by writing java-style code in scala and are struggling with refactoring it to more native scala. Somewhere we could put our fledgling code up for constructive criticism without having to keep prefacing it with Newbie question: would be good. Tim On Apr 21, 8:38 pm, Charles F. Munat c...@munat.com wrote: I am charged with coming up with a site map/information architecture for our hopefully-soon-to-be-updated wiki. What would most benefit you on a documentation wiki? What sorts of things are you having the most problems with? Please submit suggestions for a wiki outline, as well as any other ideas you have. For example, ideas on wiki structure are welcome. You could even suggest your own outline. Please participate! Yes, you, lurker! We want to know what you need. I'll collect all the ideas this weekend, consolidate them, and present a suggested outline (road map) for the documentation wiki. Thanks! Yes! If you are reading this, then I am talking to you. Speak up. Chas. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: stuck on some scala while using jpa
OK to answer own question in case anyone has similar problems: ScalaEntityManager returns a bufferWrapper from the jcl.Conversions not a List. However, it can be treated as a Seq[Postcode] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] scalajpa 1.1
Question for Derek my jpa 1.1-SNAPSHOT version seems to have disappeared from the maven repo to be replaced with 1.1 But at the same time now I've done a maven clean it looks like RequestVarEM doesn't exist any more. I just got the source from git and this seems to be the case. So what do I do with that bit of the model (or are you busy rewriting that section of the book right now ...)? Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Lift 1.1 M1 question
I'm at early stages of a fairly big project at the moment and mainly working in my domain model. Is M1 safe to use, since I doubt we'll get onto serious UI stuff for at least a month and production is likely 2-3 months after that. Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: jpa, emf Model and unit tests
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 (dddsample.sourceforge.net if you;'re interested) is to have repositories - one for each aggregate - set of linked classes (typical example is an order which aggregates order lines and possibily delivery history). The repositories are implemented as interfaces and have persistence neutral finders get all outstanding orders with credit-stopped customers for example. This is part of the domain model, but returns typical jpa/hibernate persisted objects. The implementation of the repository is hibernate aware and uses getCurrentSession() quite freely. The implementation is injected via spring. Back in my context, this means I want my repository impls to be EM or session aware too - so my original question stands - but the repository mechanism separates the domain model from the direct persistence layer which should allay your concerns. Tim On Apr 28, 6:48 am, Viktor Klang viktor.kl...@gmail.com wrote: 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: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: jpa, emf Model and unit tests
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 via navigation through the associations of those initial entities that are expressly bi-directional. The DDD model, as I understand it, takes the view that there should be no unnecessary bi-directional links and that reaching objects by searching the other side of the association is not only acceptable but to be encouraged, since it reduces the interlinking between components. This is a perfectly respectable viewpoint - not just some weird idea I've dreamed up (honest!). my sympathies are in this camp. Environments like Spring (and Grails which is what I've been working in) enable the second model, since they'll happily inject the current hibernate session (and presumably jpa EM) anywhere you want it to be injected. So it's quite straight forward to use without breaking the usage patterns. But your scalajpa follows, essentially, the stricter line that once the em has given you the first objects (presumably from a controller or service based query, thus outside the domain model), that's it. Does that correctly sum up the arguments? Tim On Apr 28, 4:31 am, Derek Chen-Becker dchenbec...@gmail.com wrote: 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 to the EntityManager that loaded them, although there may be some provider-specific way to get at it. Unfortunately, you're on your own if you want an entity to obtain other entities via queries or some other non-relationship means. Generally, if you need that kind of coverage you should do it through logic code that can glue things together instead of tying it to your entities. After all, I'd argue that if the logic isn't part of what you can express in the database then it doesn't belong in the entity classes anyways. When you say bogged down in bidirectional mappings are you referring simply to the overhead of adding the mappings to your entities, or do you think that there's some performance issue with bidirectional mappings (AFAIK, there aren't any). Derek On Mon, Apr 27, 2009 at 6:01 PM, TSP tim.pig...@optrak.co.uk wrote: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: jpa, emf Model and unit tests
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 an EMF factory (a factory-factory?)) However, in answer to the bidirectional mapping question here is an example: class City { var name: String; var population: Int; // var addresses: java.util.Set[Address] // BAD because London has approx 3m addresses } class Address { name, street etc var city: City } object Address { def matchAddress( .. unstructured input strings from ERP system ...) = { ,,, Some[Address] else None } } class Organisation { var hq: Address; } So I can easily trace from organisation to it's address and then find out if the organisation is in a big city. But I never need to directly fetch the city and iterate through the addresses. There are many more examples where the many side of things runs into hundreds and thousands (shipments to a daily customer over the last 2 years, tracking events on trucks at 1 minute intervals stored for 6 months). Again with reference to Evans Domain Driven Design for a large and complex domain model (I expect to end up with well over 50 objects) universal bi-directional mappings are strongly discouraged (see for example discussion on p. 83) Now you might argue that my address matching should be delegated to a service, but the techniques can be quite country specific tying in the postcodes and town names for example or dealing with peculiarities (from my point of view) of US street naming conventions - so I want my address matching tied closely to may data objects (in that case it would be Address subclasses). Also as soon as I do get rid of bi- directional mappings then any direct business logic that requires traversal in the missing direction can be readily accomplished by access to the database. On Apr 27, 11:00 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: 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 a valid point, and I would where possible but I've got quite a lot of uni-directional references (for example, addressable locations in a city) where using a mapping would entail very large fetches that are better handled by querying the database. Evans in Domain Driven Design is very keen on uni-directional references and who am I to argue :-) Tim On Apr 27, 9:10 pm, Viktor Klang viktor.kl...@gmail.com wrote: 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 in the book. I've got domain classes that need to go get stuff from the database list all ... type of methods. So presumably my domain class should have, or be allowed to have methods that access Model But my unit tests need to test these methods. So I need a model which is instantiated within the test environment and so does not need to be extended with RequestVarEM which presumably would be a bad thing (though perhaps it's harmless). Any suggestions on best practice to achieve this? (I'm still very much trying to find my way round natural scala constructs) Should it be mentioned in the jpa chapter in the book? Tim -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---