[Lift] Re: JPA w/Scala

2008-09-10 Thread Oliver
Hi Derek,

this is looking good

On Wed, Sep 10, 2008 at 2:55 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 OK, the code is merged in and the latest version is attached. I made a few
 minor modifications to the JPA code that Oliver sent:

 1. I made the openEM and closeEM methods abstract and protected. The idea
 is that the JPA class shouldn't be tied to the way the user wants to access
 JPA. Rather, when they implement the JPA class they can provide their own
 hooks to do direct access, IoC, or JNDI, etc.

 2. I added a convenience method for createNamedQuery so that you can pass
 parameters in when you create the query. A very minor change but it saves a
 little typing when you use it a lot.


I like this, it saves typing and reads a lot better



 I've also changed the module naming per Oliver's suggestion. I'll test
 against the other DBs this afternoon, but so far I've had no issues with
 HSQLDB.


I've also tested it against SQL Server 2000 and it runs without any problems
(unfortunately, I don't have SQL Server 2005 or later, to test against)



 Derek


 On Tue, Sep 9, 2008 at 8:35 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 Looks like I missed a lot in the two days I was gone :). I'm going to look
 at Oliver's code and merge it. As for Tim's problem with the insertions, the
 AUTO ID generation should usually just work. I don't have a SQL Server
 instance to try it out on, but after I merge the code I'll test it again
 with HSQL, PostgreSQL and MySQL to make sure that it works there. If so, it
 may be something specific to the SQL Server dialect.

 Derek


 On Tue, Sep 9, 2008 at 5:09 AM, Oliver Lambert [EMAIL PROTECTED] wrote:



 On 09/09/2008, at 7:47 PM, Tim Perrett wrote:

 
  I agree - its strange and not what we would expect.
 
  What version of SQL server are you running? Im using 2005 Enterprise
  here...
 
 I think thats what they are using at my company


  Its just a really strange thing, the 100 is always ignored... I think
  it just needs a 2nd parameter there, even if its going to ignore it.
  Thats certainly what it looks like from the SQL thats being run
  anyway. I would have thought the GenerationType.IDENTITY would mean
  that it knows not to use it in SQL inserts/updates, but obviously not.
 
 I assume that you have run a simple unit test to do an insert with
 persist e.g.
   def testOK = {

 val na = new Author()
 na.name = HELLO THERE!
 Model.persist(na)

 val authors = Model.createNamedQuery[Author]
 (findAllAuthors).getResultList()

  authors.foreach(author = {
 println(name: +author.name)
 author.books.foreach(book = println(   title: +book.title))
   })
   }

 If you are still having problems, mvn clean your project, zip it up
 and mail it to me - I'll run it tomorrow morning, when I get to work

 Oliver


  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 (and hibernate validator)

2008-09-10 Thread Tim Perrett

Out of interest, I tried playing around with hibernate-validator on
this demo to see if it works, and (as you can see below), it doesnt.

Any ideas why its doing this?

Looking at the compiled bytecode, its trying to invoke the synthesized
method name_$eq(String x$1), and for some reason, failing to call it
properly.

Anyone else's input would be interesting :)

Cheers

Tim



---
Test set: com.foo.jpaweb.model.TestJPAWeb
---
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.598
sec  FAILURE!
save_stuff(com.foo.jpaweb.model.TestJPAWeb)  Time elapsed: 1.554 sec
 ERROR!
java.lang.IllegalStateException: Could not get property value
at
org.hibernate.validator.ClassValidator.getMemberValue(ClassValidator.java:
537)
at
org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
383)
at
org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
351)
at
org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:
139)
at
org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:
172)
at
org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:
119)
at
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:
42)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:
298)
at
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:
181)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:
107)
at
org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:
49)
at
org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:
131)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
87)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at
org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:
213)
at com.foo.jpaweb.model.TestJPAWeb.save_stuff(TestJPAWeb.scala:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:
98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:
79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:
87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:
77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:
88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:
51)
at org.junit.internal.runners.JUnit4ClassRunner
$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:
27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:
37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
42)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:
62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:
140)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:
338)
at

[Lift] Re: JPA w/Scala (and hibernate validator)

2008-09-10 Thread Viktor Klang
Or just write a PropertyAccessor implementation for Scala vars?
That should do the trick.

Cheers,
Viktor

On Wed, Sep 10, 2008 at 3:22 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 Two lines lower it looks like it's trying to fetch the value
 (ClassValidator.getMemberValue), but name_$eq is the setter for a value, not
 the getter. That's probably why it's coming up with the error wrong number
 of arguments. You might try adding an explicit getter for the property
 you want to validate and put the annotation there to see if that works. The
 @BeanProperty Scala annotation might be enough to force the use ofr get/set
 by the Validator framework. Just a guess at this point.

 Derek


 On Wed, Sep 10, 2008 at 3:47 AM, Tim Perrett [EMAIL PROTECTED] wrote:


 Out of interest, I tried playing around with hibernate-validator on
 this demo to see if it works, and (as you can see below), it doesnt.

 Any ideas why its doing this?

 Looking at the compiled bytecode, its trying to invoke the synthesized
 method name_$eq(String x$1), and for some reason, failing to call it
 properly.

 Anyone else's input would be interesting :)

 Cheers

 Tim




 ---
 Test set: com.foo.jpaweb.model.TestJPAWeb

 ---
 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.598
 sec  FAILURE!
 save_stuff(com.foo.jpaweb.model.TestJPAWeb)  Time elapsed: 1.554 sec
  ERROR!
 java.lang.IllegalStateException: Could not get property value
at
 org.hibernate.validator.ClassValidator.getMemberValue(ClassValidator.java:
 537)
at

 org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
 383)
at

 org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
 351)
at

 org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:
 139)
at

 org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:
 172)
at

 org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:
 119)
at

 org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:
 42)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at

 org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:
 298)
at

 org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:
 181)
at

 org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:
 107)
at

 org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:
 49)
at

 org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:
 131)
at

 org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
 87)
at

 org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
 38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at

 org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:
 213)
at com.foo.jpaweb.model.TestJPAWeb.save_stuff(TestJPAWeb.scala:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
 39)
at

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
 25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
 org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:
 98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:
 79)
at

 org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:
 87)
at
 org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:
 77)
at
 org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at

 org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:
 88)
at

 org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:
 51)
at org.junit.internal.runners.JUnit4ClassRunner
 $1.run(JUnit4ClassRunner.java:44)
at
 org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:
 27)
at
 org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:
 37)
at
 

[Lift] Re: JPA w/Scala

2008-09-09 Thread Oliver Lambert


On 09/09/2008, at 7:47 PM, Tim Perrett wrote:


 I agree - its strange and not what we would expect.

 What version of SQL server are you running? Im using 2005 Enterprise
 here...

I think thats what they are using at my company


 Its just a really strange thing, the 100 is always ignored... I think
 it just needs a 2nd parameter there, even if its going to ignore it.
 Thats certainly what it looks like from the SQL thats being run
 anyway. I would have thought the GenerationType.IDENTITY would mean
 that it knows not to use it in SQL inserts/updates, but obviously not.

I assume that you have run a simple unit test to do an insert with  
persist e.g.
   def testOK = {

 val na = new Author()
 na.name = HELLO THERE!
 Model.persist(na)

 val authors = Model.createNamedQuery[Author] 
(findAllAuthors).getResultList()

 authors.foreach(author = {
 println(name: +author.name)
 author.books.foreach(book = println(   title: +book.title))
   })
   }

If you are still having problems, mvn clean your project, zip it up  
and mail it to me - I'll run it tomorrow morning, when I get to work

Oliver


 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

2008-09-09 Thread Derek Chen-Becker
Looks like I missed a lot in the two days I was gone :). I'm going to look
at Oliver's code and merge it. As for Tim's problem with the insertions, the
AUTO ID generation should usually just work. I don't have a SQL Server
instance to try it out on, but after I merge the code I'll test it again
with HSQL, PostgreSQL and MySQL to make sure that it works there. If so, it
may be something specific to the SQL Server dialect.

Derek

On Tue, Sep 9, 2008 at 5:09 AM, Oliver Lambert [EMAIL PROTECTED] wrote:



 On 09/09/2008, at 7:47 PM, Tim Perrett wrote:

 
  I agree - its strange and not what we would expect.
 
  What version of SQL server are you running? Im using 2005 Enterprise
  here...
 
 I think thats what they are using at my company


  Its just a really strange thing, the 100 is always ignored... I think
  it just needs a 2nd parameter there, even if its going to ignore it.
  Thats certainly what it looks like from the SQL thats being run
  anyway. I would have thought the GenerationType.IDENTITY would mean
  that it knows not to use it in SQL inserts/updates, but obviously not.
 
 I assume that you have run a simple unit test to do an insert with
 persist e.g.
   def testOK = {

 val na = new Author()
 na.name = HELLO THERE!
 Model.persist(na)

 val authors = Model.createNamedQuery[Author]
 (findAllAuthors).getResultList()

  authors.foreach(author = {
 println(name: +author.name)
 author.books.foreach(book = println(   title: +book.title))
   })
   }

 If you are still having problems, mvn clean your project, zip it up
 and mail it to me - I'll run it tomorrow morning, when I get to work

 Oliver


  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

2008-09-09 Thread Derek Chen-Becker
OK, the code is merged in and the latest version is attached. I made a few
minor modifications to the JPA code that Oliver sent:

1. I made the openEM and closeEM methods abstract and protected. The idea is
that the JPA class shouldn't be tied to the way the user wants to access
JPA. Rather, when they implement the JPA class they can provide their own
hooks to do direct access, IoC, or JNDI, etc.

2. I added a convenience method for createNamedQuery so that you can pass
parameters in when you create the query. A very minor change but it saves a
little typing when you use it a lot.

I've also changed the module naming per Oliver's suggestion. I'll test
against the other DBs this afternoon, but so far I've had no issues with
HSQLDB.

Derek

On Tue, Sep 9, 2008 at 8:35 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 Looks like I missed a lot in the two days I was gone :). I'm going to look
 at Oliver's code and merge it. As for Tim's problem with the insertions, the
 AUTO ID generation should usually just work. I don't have a SQL Server
 instance to try it out on, but after I merge the code I'll test it again
 with HSQL, PostgreSQL and MySQL to make sure that it works there. If so, it
 may be something specific to the SQL Server dialect.

 Derek


 On Tue, Sep 9, 2008 at 5:09 AM, Oliver Lambert [EMAIL PROTECTED] wrote:



 On 09/09/2008, at 7:47 PM, Tim Perrett wrote:

 
  I agree - its strange and not what we would expect.
 
  What version of SQL server are you running? Im using 2005 Enterprise
  here...
 
 I think thats what they are using at my company


  Its just a really strange thing, the 100 is always ignored... I think
  it just needs a 2nd parameter there, even if its going to ignore it.
  Thats certainly what it looks like from the SQL thats being run
  anyway. I would have thought the GenerationType.IDENTITY would mean
  that it knows not to use it in SQL inserts/updates, but obviously not.
 
 I assume that you have run a simple unit test to do an insert with
 persist e.g.
   def testOK = {

 val na = new Author()
 na.name = HELLO THERE!
 Model.persist(na)

 val authors = Model.createNamedQuery[Author]
 (findAllAuthors).getResultList()

  authors.foreach(author = {
 println(name: +author.name)
 author.books.foreach(book = println(   title: +book.title))
   })
   }

 If you are still having problems, mvn clean your project, zip it up
 and mail it to me - I'll run it tomorrow morning, when I get to work

 Oliver


  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
-~--~~~~--~~--~--~---



jpademo.tar.gz
Description: GNU Zip compressed data


[Lift] Re: JPA w/Scala

2008-09-08 Thread Tim Perrett

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

2008-09-08 Thread Oliver Lambert

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: JPA w/Scala

2008-09-08 Thread Oliver Lambert
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

2008-09-08 Thread Oliver Lambert
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

2008-09-08 Thread Tim Perrett

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: JPA w/Scala

2008-09-08 Thread Oliver
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] Re: JPA w/Scala

2008-09-07 Thread Tim Perrett

Ah cool - this is quite nice actually; good work Oliver!

@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: JPA w/Scala

2008-09-07 Thread Charles F. Munat

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!
 
 @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: JPA w/Scala - never mind

2008-09-03 Thread Derek Chen-Becker
Sorry I didn't get back to you on that. I'm working on an improved version
of the tutorial to include a complete example but it's dependent on
0.10-SNAPSHOT right now. As soon as 0.10 goes GA I'll revise the tutorial
page.

Derek

On Tue, Sep 2, 2008 at 8:35 PM, Charles F. Munat [EMAIL PROTECTED] wrote:


 I figured it out, I think. Should be author.name, without the parentheses.

 Charles F. Munat wrote:
  Has anyone followed the JPA tutorial using pure Scala instead of Java?
  I've got it very close to running, but I am getting the following error:
 
  [WARNING]
 
 /private/var/www/wsbg/webapp/src/main/scala/com/foo/jpaweb/snippet/AuthorOps.scala:22:
  error: value getName is not a member of com.foo.jpaweb.model.Author
  [WARNING]  name -- Text(author.getName()),
  [WARNING] ^
  [WARNING] one error found
 
  I'm neither a Scala nor a Java programmer, but I'm guessing that the
  getter for the name attribute in Scala is not getName. Is this correct?
 
  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: JPA w/Scala - never mind

2008-09-02 Thread Charles F. Munat

I figured it out, I think. Should be author.name, without the parentheses.

Charles F. Munat wrote:
 Has anyone followed the JPA tutorial using pure Scala instead of Java? 
 I've got it very close to running, but I am getting the following error:
 
 [WARNING] 
 /private/var/www/wsbg/webapp/src/main/scala/com/foo/jpaweb/snippet/AuthorOps.scala:22:
  
 error: value getName is not a member of com.foo.jpaweb.model.Author
 [WARNING]  name -- Text(author.getName()),
 [WARNING] ^
 [WARNING] one error found
 
 I'm neither a Scala nor a Java programmer, but I'm guessing that the 
 getter for the name attribute in Scala is not getName. Is this correct?
 
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---