[Lift] Re: JPA w/Scala
Just been doing some more debugging on this - it appears that the correct values are being passed through and are assigned to an entity instance, but they blow up when trying to do the em.merge(author) call. The stack trace I get is: ### AUTHOR [EMAIL PROTECTED] ### AUTHOR ID 0 ### AUTHOR NAME sdfsdssdfs DEBUG - opened session at timestamp: 12208732519 DEBUG - begin DEBUG - opening JDBC connection DEBUG - total checked-out connections: 0 DEBUG - using pooled JDBC connection, pool size: 0 DEBUG - current autocommit status: true DEBUG - disabling autocommit DEBUG - after transaction begin DEBUG - id unsaved-value: 0 DEBUG - transient instance of: com.foo.jpaweb.model.Author DEBUG - merging transient instance DEBUG - saving [com.foo.jpaweb.model.Author#null] DEBUG - executing insertions DEBUG - Wrapped collection in role: com.foo.jpaweb.model.Author.books DEBUG - executing identity-insert immediately DEBUG - Inserting entity: com.foo.jpaweb.model.Author (native id) DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) DEBUG - insert into authors (name, id) values (?, ?) Hibernate: insert into authors (name, id) values (?, ?) DEBUG - preparing statement DEBUG - Dehydrating entity: [com.foo.jpaweb.model.Author#null] DEBUG - binding 'sdfsdssdfs' to parameter: 1 DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) DEBUG - closing statement DEBUG - could not insert: [com.foo.jpaweb.model.Author] [insert into authors (name, id) values (?, ?)] java.sql.SQLException: Parameter #2 has not been set. at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareSQL(ConnectionJDBC2.java: 613) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA w/Scala
You know I always forget those long winded archetype creation commands and thinking about this I guess I would hope for something more. Something like specify a set of tables (and stuff) and have LiftBuilder go and create mappings, validation and default html for me. I haven't looked at it for a long time, but I believe Grails does something like this Oliver On 08/09/2008, at 9:52 AM, Charles F. Munat wrote: Oh, hell yeah. Please! And down the road, when the mapper becomes agnostic, would there be an archetype that used JPA as the back end for the Lift mapper? Chas. Tim Perrett wrote: Ah cool - this is quite nice actually; good work Oliver! Cheers @Derek, what are your thoughts? It certainly strikes me that as time wears on and more people are using the lift/jpa stuff that we should really create an archetype for it would others find that useful? Cheers 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Scripting and Maven scala plugin
Hi, I sent you an email to your gmail account did you get it? It has the patch oh. I will try to find the maven-scala mailing list Jesse On Sep 6, 7:16 pm, David Bernard [EMAIL PROTECTED] wrote: I don't known, but now I could access the site. You're goal is a great extension, and need to up the version to 2.8. If you don't know git or don't have time to prepare a patch send me the whole project, I'll do the merge. Thanks /davidB PS: could we switch the conversation to maven-and-scala mailing-list On Sat, Sep 6, 2008 at 4:58 PM, Jesse Eichar [EMAIL PROTECTED] wrote: Excuse my typing, my daughter is in one arm so I am working with one hand. Odd I can access the site... Although oddly if I add www it doesn't work. Maybe make sure that your browser doesn't add it. Tell you what. I will checkout the latest source, make a patch and send it to you. You can look it over at your leisure. Word of warning though. I have a conference coming up that I am madly preparing for so I may not find time until Early October. I will do what I can to get it to you earlier. Jesse On Sep 6, 4:46 pm, David Bernard [EMAIL PROTECTED] wrote: I can't accesshttp://pragmaticdesign.net/maven-scala-plugin-site/index.html On Sat, Sep 6, 2008 at 4:45 PM, David Bernard [EMAIL PROTECTED] wrote: Hi, Contributions are welcome (send me a patch, if possible provide the doc for the feature). FYI : * the latest source are at http://github.com/davidB/maven-scala-plugin/tree/master(svnis no more used) * I started (today) a new mailing list about maven and scala http://groups.google.com/group/maven-and-scala /davidB On Sat, Sep 6, 2008 at 4:18 PM, David Pollak [EMAIL PROTECTED] wrote: Jesse, I don't speak for DavidB, the Maven Scala plugin maintainer, but I certainly think this is a feature I'd like to see. :-) Thanks, David On Sat, Sep 6, 2008 at 7:08 AM, Jesse Eichar [EMAIL PROTECTED] wrote: Hi, Inspired by the GMaven plugin I have taken the maven-scala plugin and added a new Scripting Goal. It allows you to inline scala directly into a pom or execute a scala script from another file. In order to make it more applicable for the build process the MavenProject and Log can be optionally passed to the script. For details and code examples you can look at the updated documentation for the plugin that I put online at:http://pragmaticdesign.net/maven-scala-plugin-site/index.html I would like to contribute the change to the main maven-scala plugin. I have now used it in three very different projects so I can say that it is fairly well used and I am willing to support the scripting portion of the plugin. As for my credentials. I am Jesse Eichar and am the technical lead for the uDig (http://udig.refractions.net/) open source project, a module maintainer for two modules in the GeoTools (http:// docs.codehaus.org/display/GEOTOOLS/Home) open source project. I have contributed to the GeoAdminSuite (http://geojava.camptocamp.net/gas/) project, the GeoServer (http://geoserver.org/display/GEOS/Welcome) project, the Sextante (http://www.sextantegis.com/) project and am working on a project that will see code contributed to the GeoNetwork (http://geonetwork-opensource.org/) project. I mention these projects because I think demonstrates that I understand the philosophy of open source projects and the requirements to work with them. Please let me know how and when I can contribute the code. My changes are based on the latest from trunk. Jesse -- Lift, the simply functional web frameworkhttp://liftweb.net Collaborative Task Managementhttp://much4.us Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Missing Scala class?
What version of Lift and what version of Scala are you using? (The version of Scala that you use must match the version of Scala that was used to compile your version of Lift.) --j On Mon, Sep 8, 2008 at 10:37 AM, Kris Nuttycombe [EMAIL PROTECTED] wrote: Hi, all, I'm not sure whether this is a Lift issue or a Scala issue, but in running the Glassfish verifier over my Lift war I saw a couple of suspect failures: Failed to find following classes: [ scala.Stream$cons ] referenced in the following call stack : at scala.Stream$cons$ at scala.Stream$$anonfun$apply$1 at scala.Stream$ at scala.Stream$class at scala.RandomAccessSeq$$anon$6 at scala.RandomAccessSeq$class at scala.RandomAccessSeq$Projection$$anon$7 at scala.RandomAccessSeq$Projection$class at scala.Array$Projection$$anon$2 at scala.Array$Projection$class at scala.Array$ at scala.runtime.BoxedObjectArray at scala.runtime.StringAdd at scala.Predef at scala.Predef$$anon$2 at scala.Predef$ at scala.Iterator$$anon$3 at scala.Iterator$ at scala.Iterator$$anon$15 at scala.Iterator$class at scala.BufferedIterator$Advanced$$anon$3 at scala.BufferedIterator$Advanced$class at scala.BufferedIterator$Default at scala.Iterator$PredicatedIterator at scala.Iterator$TakeWhileIterator at scala.Iterator at scala.collection.mutable.Buffer at scala.Iterable at scala.Collection at scala.RandomAccessSeq$Projection$MapProjection at scala.RandomAccessSeq$Projection at scala.RandomAccessSeq at scala.collection.mutable.ResizableArray at scala.collection.mutable.ArrayBuffer at scala.collection.mutable.Script at scala.collection.mutable.Buffer$class at scala.collection.mutable.ListBuffer at scala.List$$anonfun$flatten$1 at scala.List at scala.Stream at scala.runtime.BoxedArray at scala.StringBuilder at scala.Tuple2 at scala.Iterable$class at scala.Seq$Projection$ComputeSize at scala.Seq$Projection at scala.Seq$Projection$class at scala.Seq$ at scala.Either$RightProjection at scala.Either at scala.Left at scala.Option at scala.Seq at scala.runtime.BoxedDoubleArray at scala.runtime.ScalaRunTime$ at net.liftweb.http.ParsePath at net.liftweb.http.LiftFilter Any ideas? Thanks, Kris --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA w/Scala
I think sql server uses @GeneratedValue(strategy=GenerationType.IDENTITY) You could try this instead of GenerationType.AUTO (though this should translate to the above) Oliver On 09/09/2008, at 12:43 AM, Tim Perrett wrote: Hmmm, I've tried: @Id @GeneratedValue(){val strategy = GenerationType.AUTO} @Column(){val insertable = false} var id : Long = _ But yet its still being included in the query, any ideas? Cheers, 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA w/Scala
or, you could try @GeneratedValue(strategy = GenerationType.AUTO, generator = system-guid) @GenericGenerator(name = system-guid, strategy = guid) with or without the Microsoft driver property name=driverClassName valuecom.microsoft.sqlserver.jdbc.SQLServerDriver/value /property and the pom entry !dependency groupIdMSSQLDriver/groupId artifactIdsqljdbc/artifactId version1.1.1501.101/version /dependency On 09/09/2008, at 4:05 AM, Oliver Lambert wrote: I think sql server uses @GeneratedValue(strategy=GenerationType.IDENTITY) You could try this instead of GenerationType.AUTO (though this should translate to the above) Oliver On 09/09/2008, at 12:43 AM, Tim Perrett wrote: Hmmm, I've tried: @Id @GeneratedValue(){val strategy = GenerationType.AUTO} @Column(){val insertable = false} var id : Long = _ But yet its still being included in the query, any ideas? Cheers, 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA w/Scala
Hey all, Very strange, I re-wrote the classes in Java and I still see the same issue!!! What on earth could be going on here? I tried calling persist rather than merge, but it appeared to have no impact. Cheers 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: One further: JPA + JTA + Lift
It looks a little like the RequestVar has had its lifecycle closing hook called by the time you call getSubscriptions Try touch/get the subscriptions before you pass them into the bind. cheers Oliver On Tue, Sep 9, 2008 at 7:31 AM, Kris Nuttycombe [EMAIL PROTECTED]wrote: I've been following the advancement of the JPA/Lift tutorial with great interest, and have managed to get my app working, but I'm now struggling with a problem that occurs whenever I try to retrieve a collection that is mapped as a lazy association: Exception occured while processing /orders/list Message: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.gaiam.gcsi.entities.subscription.Order.subscriptions, no session or session was closed org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97) org.hibernate.collection.PersistentBag.size(PersistentBag.java:225) com.gaiam.gcsi.snippet.Orders$$anonfun$list$1.apply(Orders.scala:21) com.gaiam.gcsi.snippet.Orders$$anonfun$list$1.apply(Orders.scala:18) scala.Seq$class.flatMap(Seq.scala:267) com.gaiam.gcsi.model.EM$$anon$1.flatMap(EM.scala:11) com.gaiam.gcsi.snippet.Orders.list(Orders.scala:18) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... I took the simplest-possible route of encapsulating the EntityManager in a RequestVar per Derek's suggestion as such: object EM { def entityManager() = (new InitialContext()).lookup(java:comp/env/persistence/em).asInstanceOf[EntityManager] } class Orders { object em extends RequestVar(entityManager()) def list(xhtml: NodeSeq) : NodeSeq = { val orders = em.createQuery(from Order).getResultList().asInstanceOf[java.util.List[Order]] orders.flatMap(order = bind(order, xhtml, id -- Text(order.getId().toString), count -- Text(order.getSubscriptions().size().toString))) } } The issue appears to be that the transaction that the the query ran in is no longer active by the time of the call to order.getSubscriptions(). Has anyone else been using JTA and encountered this? I'm running the latest stable Glassfish (2.1 UR2) and using Hibernate for the persistence layer. Thanks, Kris --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA w/Scala
Doesn't look right. The id is the primary key - it could now be inserted with a value of 100, always. I can do an insert here with @Id @GeneratedValue(){val strategy = GenerationType.AUTO} Still works without GeneratedValue being present. My pom dependencies are dependency groupIdorg.hibernate/groupId artifactIdhibernate-entitymanager/artifactId version3.3.2.GA/version /dependency dependency groupIdnet.sourceforge.jtds/groupId artifactIdjtds/artifactId version1.2/version /dependency Properties in persistance.xml properties property name=hibernate.dialect value=org.hibernate.dialect.SQLServerDialect/ property name=hibernate.connection.driver_class value=net.sourceforge.jtds.jdbc.Driver/ property name=hibernate.connection.username value=xx/ property name=hibernate.connection.password value=xx/ property name=hibernate.connection.url value=jdbc:jtds:sqlserver://localhost:1433/fred/ property name=hibernate.max_fetch_depth value=3/ property name=hibernate.show_sql value=true/ /properties On Tue, Sep 9, 2008 at 9:37 AM, Tim Perrett [EMAIL PROTECTED] wrote: I managed to fix it in the end by reading some really really old post in the hibernate archive. Effectively, if you define something, a class property that has no initial value (in our case, _ ) then it bones the inserting for some reason. Quite knows what it does that but it does.. and with very little error as well :-( For completeness sake, here is the final Author class: @Entity @Table(){val name=authors, val schema=dbo} class Author { @Id @GeneratedValue(){val strategy = GenerationType.IDENTITY} @Column(){val insertable = false, val unique = true} var id : Long = 100 var name : String = @OneToMany(){val mappedBy = author, val targetEntity = classOf[Book]} var books : java.util.Set[Book] = new java.util.HashSet[Book]() } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Maven Issue
Hi There, I'm following the instructions here: http://liftweb.net/index.php/HowTo_start_a_new_liftwebapp ...and I can build the liftone application. However...when I do this: ^Cbash-3.00$ mvn jetty:run -U http://scala-tools.org/repo-releases/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar [removed let's download the Internet] Downloading: http://cvs.apache.org/maven-snapshot-repository/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar ...and it can't find that. I can't ping cvs.apache.org org or contact it. I don't understand enough about Maven to be able to figure out how to get the jar into the right place, nor to know whether I've given enough information. I've looked at the Maven FAQs about how to do it but I have no idea what an artifact-id is or the structure of my Maven directory... Has anyone got any pointers as to what I might do or for a simple hand- holding tutorial? DSL --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---