[Lift] Re: JPA and auto generation of id

2009-06-22 Thread Oliver Lambert
What sort of database are you trying to use Hibernate against (look at the
property hibernate.dialect  in the file persistence.xml)?
I think the error may mean that your trying to use GenerationType.AUTO
against a database that doesn't support it.
On Mon, Jun 22, 2009 at 7:08 PM, David Persons  wrote:

>
> Hello guys,
>
> I get a org.hibernate.exception.SQLGrammarException: could not get or
> update next value error everytime I try to save the following Entity:
>
> @Entity
> class Scene {
>  @Id
>  @GeneratedValue(){val strategy = GenerationType.AUTO}
>  var id : Long = _
>
>  @Column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
>  @Column{val unique = true, val nullable = false}
>  var name : String = ""
>
>  @ManyToOne{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> What am I doing wrong??
>
> grtz,
> David Persons
>
> >
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Mojo

My guess:  It depends on the DB you're using.  If it's Oracle, you may
need to create a sequence for the table ID. Alternatively your ORM
configuration may need to know what dialect of database to use.

Mojo
--
Morris Jones
Monrovia, CA
m...@whiteoaks.com
http://mojo.whiteoaks.com

On Sun, Jun 21, 2009 at 4:31 PM, David Persons wrote:
>
> Hello guys,
>
> I switched from the Mapper Framework to JPA. Example of one of the
> entities:
>
> @Entity
> class Scene {
> �...@id
> �...@generatedvalue(){val strategy = GenerationType.AUTO}
>  var id : Long = _
>
> �...@column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
> �...@column{val unique = true, val nullable = false}
>  var name : String = ""
>
> �...@manytoone{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> When trying to save a new Scene, I keep getting the following error:
> org.hibernate.exception.SQLGrammarException: could not get or update
> next value
>
> What can be the problem??
>
> regards,
> David
>
> >
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Eric Bowman

David Persons wrote:
> Hello guys,
>
> I get a org.hibernate.exception.SQLGrammarException: could not get or
> update next value error everytime I try to save the following Entity:
>
> @Entity
> class Scene {
>   @Id
>   @GeneratedValue(){val strategy = GenerationType.AUTO}
>   var id : Long = _
>
>   @Column{val unique = true, val nullable = false}
>   var ordering : Int = _
>
>   @Column{val unique = true, val nullable = false}
>   var name : String = ""
>
>   @ManyToOne{val optional = false}
>   var storyBoard : StoryBoard = _
> }
>
>   

You almost certainly need some scala.reflect.BeanProperty annotations on
your fields.

cheers,
Eric

-- 
Eric Bowman
Boboco Ltd
ebow...@boboco.ie
http://www.boboco.ie/ebowman/pubkey.pgp
+35318394189/+353872801532


--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Derek Chen-Becker
That's not accurate, at least with Hibernate. By putting the annotations on
vars, the compiler ends up putting them on the internal fields, which then
forces Hibernate into a field-based persistence model and not a
getter/setter based one. The SQLGrammarException is most likely what the
other people have said. If you're in Oracle or PostgreSQL, for instance, you
need a sequence set up for the auto identity model. What database are you
using?

Derek

On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:

>
> David Persons wrote:
> > Hello guys,
> >
> > I get a org.hibernate.exception.SQLGrammarException: could not get or
> > update next value error everytime I try to save the following Entity:
> >
> > @Entity
> > class Scene {
> >   @Id
> >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> >   var id : Long = _
> >
> >   @Column{val unique = true, val nullable = false}
> >   var ordering : Int = _
> >
> >   @Column{val unique = true, val nullable = false}
> >   var name : String = ""
> >
> >   @ManyToOne{val optional = false}
> >   var storyBoard : StoryBoard = _
> > }
> >
> >
>
> You almost certainly need some scala.reflect.BeanProperty annotations on
> your fields.
>
> cheers,
> Eric
>
> --
> Eric Bowman
> Boboco Ltd
> ebow...@boboco.ie
> http://www.boboco.ie/ebowman/pubkey.pgp
> +35318394189/+353872801532
>
>
> >
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Meredith Gregory
David,

i recently ran into an issue that smells exactly like this. For hibernate i
had to do the following:

@Id
@GeneratedValue(){generator = "system-uuid"}
@GenericGenerator(){name = "system-uuid", strategy = "uuid"}

This is hibernate specific. This was for an Id property that was typed
String.

Best wishes,

--greg

On Mon, Jun 22, 2009 at 2:08 AM, David Persons  wrote:

>
> Hello guys,
>
> I get a org.hibernate.exception.SQLGrammarException: could not get or
> update next value error everytime I try to save the following Entity:
>
> @Entity
> class Scene {
>  @Id
>  @GeneratedValue(){val strategy = GenerationType.AUTO}
>  var id : Long = _
>
>  @Column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
>  @Column{val unique = true, val nullable = false}
>  var name : String = ""
>
>  @ManyToOne{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> What am I doing wrong??
>
> grtz,
> David Persons
>
> >
>


-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread David Persons

I am using MySql (5). After setting the hibernate.dialect to
org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
org.hibernate.AssertionFailure: null id :-s

cheers

On 22 jun, 19:18, Derek Chen-Becker  wrote:
> That's not accurate, at least with Hibernate. By putting the annotations on
> vars, the compiler ends up putting them on the internal fields, which then
> forces Hibernate into a field-based persistence model and not a
> getter/setter based one. The SQLGrammarException is most likely what the
> other people have said. If you're in Oracle or PostgreSQL, for instance, you
> need a sequence set up for the auto identity model. What database are you
> using?
>
> Derek
>
> On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:
>
> > David Persons wrote:
> > > Hello guys,
>
> > > I get a org.hibernate.exception.SQLGrammarException: could not get or
> > > update next value error everytime I try to save the following Entity:
>
> > > @Entity
> > > class Scene {
> > >   @Id
> > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> > >   var id : Long = _
>
> > >   @Column{val unique = true, val nullable = false}
> > >   var ordering : Int = _
>
> > >   @Column{val unique = true, val nullable = false}
> > >   var name : String = ""
>
> > >   @ManyToOne{val optional = false}
> > >   var storyBoard : StoryBoard = _
> > > }
>
> > You almost certainly need some scala.reflect.BeanProperty annotations on
> > your fields.
>
> > cheers,
> > Eric
>
> > --
> > Eric Bowman
> > Boboco Ltd
> > ebow...@boboco.ie
> >http://www.boboco.ie/ebowman/pubkey.pgp
> > +35318394189/+353872801532

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Derek Chen-Becker
Mind posting the snippet of code where you're saving the instance? A merge
should interpret a null ID as a fresh instance, and a persist should just
save it.

Derek

On Mon, Jun 22, 2009 at 1:50 PM, David Persons  wrote:

>
> I am using MySql (5). After setting the hibernate.dialect to
> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
> org.hibernate.AssertionFailure: null id :-s
>
> cheers
>
> On 22 jun, 19:18, Derek Chen-Becker  wrote:
> > That's not accurate, at least with Hibernate. By putting the annotations
> on
> > vars, the compiler ends up putting them on the internal fields, which
> then
> > forces Hibernate into a field-based persistence model and not a
> > getter/setter based one. The SQLGrammarException is most likely what the
> > other people have said. If you're in Oracle or PostgreSQL, for instance,
> you
> > need a sequence set up for the auto identity model. What database are you
> > using?
> >
> > Derek
> >
> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:
> >
> > > David Persons wrote:
> > > > Hello guys,
> >
> > > > I get a org.hibernate.exception.SQLGrammarException: could not get or
> > > > update next value error everytime I try to save the following Entity:
> >
> > > > @Entity
> > > > class Scene {
> > > >   @Id
> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> > > >   var id : Long = _
> >
> > > >   @Column{val unique = true, val nullable = false}
> > > >   var ordering : Int = _
> >
> > > >   @Column{val unique = true, val nullable = false}
> > > >   var name : String = ""
> >
> > > >   @ManyToOne{val optional = false}
> > > >   var storyBoard : StoryBoard = _
> > > > }
> >
> > > You almost certainly need some scala.reflect.BeanProperty annotations
> on
> > > your fields.
> >
> > > cheers,
> > > Eric
> >
> > > --
> > > Eric Bowman
> > > Boboco Ltd
> > > ebow...@boboco.ie
> > >http://www.boboco.ie/ebowman/pubkey.pgp
> > > +35318394189/+353872801532<
> http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>
> >
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-22 Thread Derek Chen-Becker
Also, what does the schema for the entity's table look like?

On Mon, Jun 22, 2009 at 4:54 PM, Derek Chen-Becker wrote:

> Mind posting the snippet of code where you're saving the instance? A merge
> should interpret a null ID as a fresh instance, and a persist should just
> save it.
>
> Derek
>
>
> On Mon, Jun 22, 2009 at 1:50 PM, David Persons wrote:
>
>>
>> I am using MySql (5). After setting the hibernate.dialect to
>> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
>> org.hibernate.AssertionFailure: null id :-s
>>
>> cheers
>>
>> On 22 jun, 19:18, Derek Chen-Becker  wrote:
>> > That's not accurate, at least with Hibernate. By putting the annotations
>> on
>> > vars, the compiler ends up putting them on the internal fields, which
>> then
>> > forces Hibernate into a field-based persistence model and not a
>> > getter/setter based one. The SQLGrammarException is most likely what the
>> > other people have said. If you're in Oracle or PostgreSQL, for instance,
>> you
>> > need a sequence set up for the auto identity model. What database are
>> you
>> > using?
>> >
>> > Derek
>> >
>> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:
>> >
>> > > David Persons wrote:
>> > > > Hello guys,
>> >
>> > > > I get a org.hibernate.exception.SQLGrammarException: could not get
>> or
>> > > > update next value error everytime I try to save the following
>> Entity:
>> >
>> > > > @Entity
>> > > > class Scene {
>> > > >   @Id
>> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
>> > > >   var id : Long = _
>> >
>> > > >   @Column{val unique = true, val nullable = false}
>> > > >   var ordering : Int = _
>> >
>> > > >   @Column{val unique = true, val nullable = false}
>> > > >   var name : String = ""
>> >
>> > > >   @ManyToOne{val optional = false}
>> > > >   var storyBoard : StoryBoard = _
>> > > > }
>> >
>> > > You almost certainly need some scala.reflect.BeanProperty annotations
>> on
>> > > your fields.
>> >
>> > > cheers,
>> > > Eric
>> >
>> > > --
>> > > Eric Bowman
>> > > Boboco Ltd
>> > > ebow...@boboco.ie
>> > >http://www.boboco.ie/ebowman/pubkey.pgp
>> > > +35318394189/+353872801532<
>> http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-24 Thread David Persons

Thanks for all the answers guys.

I managed to fix the id problem, I needed the Hibernate specific class
GenericGenerator to fix it, which of cource is less pretty then using
only JPA. Someone has an example of how to make it work with MySql and
only JPA annotations? Current version:

@Entity
class Scene {
  @Id
  @GenericGenerator{val name="hibernate-increment", val
strategy="increment"}
  @GeneratedValue{val strategy = GenerationType.SEQUENCE, val
generator = "hibernate-increment"}
  var id : Long = _

  @Column{val unique = true, val nullable = false}
  var ordering : Int = _

  @Column{val unique = true, val nullable = false}
  var name : String = ""

  @ManyToOne{val optional = false}
  var storyBoard : StoryBoard = _
}

However, now I get an org.hibernate.PropertyValueException: not-null
property references a null or transient value:
model.Scene.storyBoard :-s I tried a lot of things already, the
corresponding StoryBoard is saved and not null, so I guess it has to
be transient. Merging the StoryBoard however still gives the same
error..

I tried to get JPA and Lift working together in the same way as in the
JPADemo example.. Is it the use of MySql which prevents the example
from working for me?

regards,
David

On 23 jun, 00:54, Derek Chen-Becker  wrote:
> Also, what does the schema for the entity's table look like?
>
> On Mon, Jun 22, 2009 at 4:54 PM, Derek Chen-Becker 
> wrote:
>
> > Mind posting the snippet of code where you're saving the instance? A merge
> > should interpret a null ID as a fresh instance, and a persist should just
> > save it.
>
> > Derek
>
> > On Mon, Jun 22, 2009 at 1:50 PM, David Persons wrote:
>
> >> I am using MySql (5). After setting the hibernate.dialect to
> >> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
> >> org.hibernate.AssertionFailure: null id :-s
>
> >> cheers
>
> >> On 22 jun, 19:18, Derek Chen-Becker  wrote:
> >> > That's not accurate, at least with Hibernate. By putting the annotations
> >> on
> >> > vars, the compiler ends up putting them on the internal fields, which
> >> then
> >> > forces Hibernate into a field-based persistence model and not a
> >> > getter/setter based one. The SQLGrammarException is most likely what the
> >> > other people have said. If you're in Oracle or PostgreSQL, for instance,
> >> you
> >> > need a sequence set up for the auto identity model. What database are
> >> you
> >> > using?
>
> >> > Derek
>
> >> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:
>
> >> > > David Persons wrote:
> >> > > > Hello guys,
>
> >> > > > I get a org.hibernate.exception.SQLGrammarException: could not get
> >> or
> >> > > > update next value error everytime I try to save the following
> >> Entity:
>
> >> > > > @Entity
> >> > > > class Scene {
> >> > > >   @Id
> >> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> >> > > >   var id : Long = _
>
> >> > > >   @Column{val unique = true, val nullable = false}
> >> > > >   var ordering : Int = _
>
> >> > > >   @Column{val unique = true, val nullable = false}
> >> > > >   var name : String = ""
>
> >> > > >   @ManyToOne{val optional = false}
> >> > > >   var storyBoard : StoryBoard = _
> >> > > > }
>
> >> > > You almost certainly need some scala.reflect.BeanProperty annotations
> >> on
> >> > > your fields.
>
> >> > > cheers,
> >> > > Eric
>
> >> > > --
> >> > > Eric Bowman
> >> > > Boboco Ltd
> >> > > ebow...@boboco.ie
> >> > >http://www.boboco.ie/ebowman/pubkey.pgp
> >> > > +35318394189/+353872801532<
> >>http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-24 Thread Bryan

Try upgrading your hibernate version from 3.3.1.ga to 3.3.2.GA.

Derek, can you look into upgrading the archetype to this release as
well?  I recall 3.3.1.ga having some packaging issues.

--Bryan

On Wed, Jun 24, 2009 at 6:29 PM, David Persons wrote:
>
> Thanks for all the answers guys.
>
> I managed to fix the id problem, I needed the Hibernate specific class
> GenericGenerator to fix it, which of cource is less pretty then using
> only JPA. Someone has an example of how to make it work with MySql and
> only JPA annotations? Current version:
>
> @Entity
> class Scene {
> �...@id
> �...@genericgenerator{val name="hibernate-increment", val
> strategy="increment"}
> �...@generatedvalue{val strategy = GenerationType.SEQUENCE, val
> generator = "hibernate-increment"}
>  var id : Long = _
>
> �...@column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
> �...@column{val unique = true, val nullable = false}
>  var name : String = ""
>
> �...@manytoone{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> However, now I get an org.hibernate.PropertyValueException: not-null
> property references a null or transient value:
> model.Scene.storyBoard :-s I tried a lot of things already, the
> corresponding StoryBoard is saved and not null, so I guess it has to
> be transient. Merging the StoryBoard however still gives the same
> error..
>
> I tried to get JPA and Lift working together in the same way as in the
> JPADemo example.. Is it the use of MySql which prevents the example
> from working for me?
>
> regards,
> David
>
> On 23 jun, 00:54, Derek Chen-Becker  wrote:
>> Also, what does the schema for the entity's table look like?
>>
>> On Mon, Jun 22, 2009 at 4:54 PM, Derek Chen-Becker 
>> wrote:
>>
>> > Mind posting the snippet of code where you're saving the instance? A merge
>> > should interpret a null ID as a fresh instance, and a persist should just
>> > save it.
>>
>> > Derek
>>
>> > On Mon, Jun 22, 2009 at 1:50 PM, David Persons wrote:
>>
>> >> I am using MySql (5). After setting the hibernate.dialect to
>> >> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
>> >> org.hibernate.AssertionFailure: null id :-s
>>
>> >> cheers
>>
>> >> On 22 jun, 19:18, Derek Chen-Becker  wrote:
>> >> > That's not accurate, at least with Hibernate. By putting the annotations
>> >> on
>> >> > vars, the compiler ends up putting them on the internal fields, which
>> >> then
>> >> > forces Hibernate into a field-based persistence model and not a
>> >> > getter/setter based one. The SQLGrammarException is most likely what the
>> >> > other people have said. If you're in Oracle or PostgreSQL, for instance,
>> >> you
>> >> > need a sequence set up for the auto identity model. What database are
>> >> you
>> >> > using?
>>
>> >> > Derek
>>
>> >> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman  wrote:
>>
>> >> > > David Persons wrote:
>> >> > > > Hello guys,
>>
>> >> > > > I get a org.hibernate.exception.SQLGrammarException: could not get
>> >> or
>> >> > > > update next value error everytime I try to save the following
>> >> Entity:
>>
>> >> > > > @Entity
>> >> > > > class Scene {
>> >> > > >   @Id
>> >> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
>> >> > > >   var id : Long = _
>>
>> >> > > >   @Column{val unique = true, val nullable = false}
>> >> > > >   var ordering : Int = _
>>
>> >> > > >   @Column{val unique = true, val nullable = false}
>> >> > > >   var name : String = ""
>>
>> >> > > >   @ManyToOne{val optional = false}
>> >> > > >   var storyBoard : StoryBoard = _
>> >> > > > }
>>
>> >> > > You almost certainly need some scala.reflect.BeanProperty annotations
>> >> on
>> >> > > your fields.
>>
>> >> > > cheers,
>> >> > > Eric
>>
>> >> > > --
>> >> > > Eric Bowman
>> >> > > Boboco Ltd
>> >> > > ebow...@boboco.ie
>> >> > >http://www.boboco.ie/ebowman/pubkey.pgp
>> >> > > +35318394189/+353872801532<
>> >>http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>
> >
>

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-24 Thread Meredith Gregory
David,

The GenericGenerator annotation was the solution i found worked for me for
Hibernate 3.3.2GA, and the one i suggested you investigate. i'm glad you've
gotten past that one.

Best wishes,

--greg

On Wed, Jun 24, 2009 at 3:29 PM, David Persons  wrote:

>
> Thanks for all the answers guys.
>
> I managed to fix the id problem, I needed the Hibernate specific class
> GenericGenerator to fix it, which of cource is less pretty then using
> only JPA. Someone has an example of how to make it work with MySql and
> only JPA annotations? Current version:
>
> @Entity
> class Scene {
>  @Id
>  @GenericGenerator{val name="hibernate-increment", val
> strategy="increment"}
>  @GeneratedValue{val strategy = GenerationType.SEQUENCE, val
> generator = "hibernate-increment"}
>   var id : Long = _
>
>  @Column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
>  @Column{val unique = true, val nullable = false}
>  var name : String = ""
>
>  @ManyToOne{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> However, now I get an org.hibernate.PropertyValueException: not-null
> property references a null or transient value:
> model.Scene.storyBoard :-s I tried a lot of things already, the
> corresponding StoryBoard is saved and not null, so I guess it has to
> be transient. Merging the StoryBoard however still gives the same
> error..
>
> I tried to get JPA and Lift working together in the same way as in the
> JPADemo example.. Is it the use of MySql which prevents the example
> from working for me?
>
> regards,
> David
>
> On 23 jun, 00:54, Derek Chen-Becker  wrote:
> > Also, what does the schema for the entity's table look like?
> >
> > On Mon, Jun 22, 2009 at 4:54 PM, Derek Chen-Becker <
> dchenbec...@gmail.com>wrote:
> >
> > > Mind posting the snippet of code where you're saving the instance? A
> merge
> > > should interpret a null ID as a fresh instance, and a persist should
> just
> > > save it.
> >
> > > Derek
> >
> > > On Mon, Jun 22, 2009 at 1:50 PM, David Persons  >wrote:
> >
> > >> I am using MySql (5). After setting the hibernate.dialect to
> > >> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
> > >> org.hibernate.AssertionFailure: null id :-s
> >
> > >> cheers
> >
> > >> On 22 jun, 19:18, Derek Chen-Becker  wrote:
> > >> > That's not accurate, at least with Hibernate. By putting the
> annotations
> > >> on
> > >> > vars, the compiler ends up putting them on the internal fields,
> which
> > >> then
> > >> > forces Hibernate into a field-based persistence model and not a
> > >> > getter/setter based one. The SQLGrammarException is most likely what
> the
> > >> > other people have said. If you're in Oracle or PostgreSQL, for
> instance,
> > >> you
> > >> > need a sequence set up for the auto identity model. What database
> are
> > >> you
> > >> > using?
> >
> > >> > Derek
> >
> > >> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman 
> wrote:
> >
> > >> > > David Persons wrote:
> > >> > > > Hello guys,
> >
> > >> > > > I get a org.hibernate.exception.SQLGrammarException: could not
> get
> > >> or
> > >> > > > update next value error everytime I try to save the following
> > >> Entity:
> >
> > >> > > > @Entity
> > >> > > > class Scene {
> > >> > > >   @Id
> > >> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> > >> > > >   var id : Long = _
> >
> > >> > > >   @Column{val unique = true, val nullable = false}
> > >> > > >   var ordering : Int = _
> >
> > >> > > >   @Column{val unique = true, val nullable = false}
> > >> > > >   var name : String = ""
> >
> > >> > > >   @ManyToOne{val optional = false}
> > >> > > >   var storyBoard : StoryBoard = _
> > >> > > > }
> >
> > >> > > You almost certainly need some scala.reflect.BeanProperty
> annotations
> > >> on
> > >> > > your fields.
> >
> > >> > > cheers,
> > >> > > Eric
> >
> > >> > > --
> > >> > > Eric Bowman
> > >> > > Boboco Ltd
> > >> > > ebow...@boboco.ie
> > >> > >http://www.boboco.ie/ebowman/pubkey.pgp
> > >> > > +35318394189/+353872801532<
> > >>http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>
> >
>


-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

--~--~-~--~~~---~--~~
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 and auto generation of id

2009-06-25 Thread Derek Chen-Becker
I've used JPA with MySQL in the past and I don't recall having to specify a
generator to get auto-incremenet IDs working. Does the schema for this
particular entity have AUTO_INCREMENT set for the id column?

Derek

On Wed, Jun 24, 2009 at 5:29 PM, David Persons  wrote:

>
> Thanks for all the answers guys.
>
> I managed to fix the id problem, I needed the Hibernate specific class
> GenericGenerator to fix it, which of cource is less pretty then using
> only JPA. Someone has an example of how to make it work with MySql and
> only JPA annotations? Current version:
>
> @Entity
> class Scene {
>  @Id
>  @GenericGenerator{val name="hibernate-increment", val
> strategy="increment"}
>  @GeneratedValue{val strategy = GenerationType.SEQUENCE, val
> generator = "hibernate-increment"}
>   var id : Long = _
>
>  @Column{val unique = true, val nullable = false}
>  var ordering : Int = _
>
>  @Column{val unique = true, val nullable = false}
>  var name : String = ""
>
>  @ManyToOne{val optional = false}
>  var storyBoard : StoryBoard = _
> }
>
> However, now I get an org.hibernate.PropertyValueException: not-null
> property references a null or transient value:
> model.Scene.storyBoard :-s I tried a lot of things already, the
> corresponding StoryBoard is saved and not null, so I guess it has to
> be transient. Merging the StoryBoard however still gives the same
> error..
>
> I tried to get JPA and Lift working together in the same way as in the
> JPADemo example.. Is it the use of MySql which prevents the example
> from working for me?
>
> regards,
> David
>
> On 23 jun, 00:54, Derek Chen-Becker  wrote:
> > Also, what does the schema for the entity's table look like?
> >
> > On Mon, Jun 22, 2009 at 4:54 PM, Derek Chen-Becker <
> dchenbec...@gmail.com>wrote:
> >
> > > Mind posting the snippet of code where you're saving the instance? A
> merge
> > > should interpret a null ID as a fresh instance, and a persist should
> just
> > > save it.
> >
> > > Derek
> >
> > > On Mon, Jun 22, 2009 at 1:50 PM, David Persons  >wrote:
> >
> > >> I am using MySql (5). After setting the hibernate.dialect to
> > >> org.hibernate.dialect.MySQLDialect in my persistence.xml file, I get a
> > >> org.hibernate.AssertionFailure: null id :-s
> >
> > >> cheers
> >
> > >> On 22 jun, 19:18, Derek Chen-Becker  wrote:
> > >> > That's not accurate, at least with Hibernate. By putting the
> annotations
> > >> on
> > >> > vars, the compiler ends up putting them on the internal fields,
> which
> > >> then
> > >> > forces Hibernate into a field-based persistence model and not a
> > >> > getter/setter based one. The SQLGrammarException is most likely what
> the
> > >> > other people have said. If you're in Oracle or PostgreSQL, for
> instance,
> > >> you
> > >> > need a sequence set up for the auto identity model. What database
> are
> > >> you
> > >> > using?
> >
> > >> > Derek
> >
> > >> > On Mon, Jun 22, 2009 at 8:54 AM, Eric Bowman 
> wrote:
> >
> > >> > > David Persons wrote:
> > >> > > > Hello guys,
> >
> > >> > > > I get a org.hibernate.exception.SQLGrammarException: could not
> get
> > >> or
> > >> > > > update next value error everytime I try to save the following
> > >> Entity:
> >
> > >> > > > @Entity
> > >> > > > class Scene {
> > >> > > >   @Id
> > >> > > >   @GeneratedValue(){val strategy = GenerationType.AUTO}
> > >> > > >   var id : Long = _
> >
> > >> > > >   @Column{val unique = true, val nullable = false}
> > >> > > >   var ordering : Int = _
> >
> > >> > > >   @Column{val unique = true, val nullable = false}
> > >> > > >   var name : String = ""
> >
> > >> > > >   @ManyToOne{val optional = false}
> > >> > > >   var storyBoard : StoryBoard = _
> > >> > > > }
> >
> > >> > > You almost certainly need some scala.reflect.BeanProperty
> annotations
> > >> on
> > >> > > your fields.
> >
> > >> > > cheers,
> > >> > > Eric
> >
> > >> > > --
> > >> > > Eric Bowman
> > >> > > Boboco Ltd
> > >> > > ebow...@boboco.ie
> > >> > >http://www.boboco.ie/ebowman/pubkey.pgp
> > >> > > +35318394189/+353872801532<
> > >>http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>
> >
>

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