Re: Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Genís Pujol

Al 09/06/2010 16:24, En/na Thiago H. de Paula Figueiredo ha escrit:
On Wed, 09 Jun 2010 11:18:16 -0300, Genís Pujol 
 wrote:


The database (Oracle 10g) has an index so it knows which Id to assign 
next to the new record, but instead of this the new object gets Id = 
0 (the next one Id=1 and so forth).
It should be the db who assigns the right Id to the new record, but I 
don't know why this isn't happening...


I've tried with

@GeneratedValue(strategy = GenerationType.IDENTITY)

and

@GeneratedValue(strategy = GenerationType.AUTO)

with the same result (id=0)


Again, use Long instead of long for the id. Have you looked at the 
table to see what's the id of the created line?


By the way, what you're having has nothing to do with Tapestry or 
Tapestry Hibernate, it's just a Hibernate issue.



OK guys, thanks for your help.

G.



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Thiago H. de Paula Figueiredo
On Wed, 09 Jun 2010 11:18:16 -0300, Genís Pujol   
wrote:


The database (Oracle 10g) has an index so it knows which Id to assign  
next to the new record, but instead of this the new object gets Id = 0  
(the next one Id=1 and so forth).
It should be the db who assigns the right Id to the new record, but I  
don't know why this isn't happening...


I've tried with

@GeneratedValue(strategy = GenerationType.IDENTITY)

and

@GeneratedValue(strategy = GenerationType.AUTO)

with the same result (id=0)


Again, use Long instead of long for the id. Have you looked at the table  
to see what's the id of the created line?


By the way, what you're having has nothing to do with Tapestry or Tapestry  
Hibernate, it's just a Hibernate issue.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Genís Pujol

Al 09/06/2010 14:27, En/na Thiago H. de Paula Figueiredo ha escrit:
On Wed, 09 Jun 2010 09:16:55 -0300, Everton Agner 
 wrote:


I'm not a Hibernate advanced user, but you're using a XML and Entity 
class annotations to configure your Entity?


I haven't noticed that. Ewerton is right: no need to use XML mappings 
when you use annotations.


Anyways... If you want your app to automatically increment your ID 
before saving it, you shouldn't use the:


In this case, it isn't the app the increments the ID, the database does.





Or @GeneratedValue.



thanks for the replies :)

I generate the classes using eclipse hibernate plugin, which creates the 
xml and the classes with the annotations (redundant I know, but doesn't 
matter atm).


The database (Oracle 10g) has an index so it knows which Id to assign 
next to the new record, but instead of this the new object gets Id = 0 
(the next one Id=1 and so forth).
It should be the db who assigns the right Id to the new record, but I 
don't know why this isn't happening...


I've tried with

@GeneratedValue(strategy = GenerationType.IDENTITY)

and

@GeneratedValue(strategy = GenerationType.AUTO)

with the same result (id=0)



hm...

Genis


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Res: Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Everton Agner
And I guess only your Annotations are being loaded. If so, try adding:

@GeneratedValue(strategy = GenerationType.IDENTITY)

to your ID getter.

I believe tapestry hib module only works (automatically) with Entity 
Annotations.

Sorry folks for the two mails.


- Everton






De: Everton Agner 
Para: Tapestry users 
Enviadas: Quarta-feira, 9 de Junho de 2010 9:16:55
Assunto: Res: Res: Res: session.persist saves object with id 0


I'm not a Hibernate advanced user, but you're using a XML and Entity class 
annotations to configure your Entity?

Anyways... If you want your app to automatically increment your ID before 
saving it, you shouldn't use the:



That tells hibernate that you want to programatically set the ID.

I guess you should use...



...instead. Try it out, i guess it will work.


- Everton




De: Genís Pujol 
Para: Tapestry users 
Enviadas: Quarta-feira, 9 de Junho de 2010 4:12:31
Assunto: Re: Res: Res: session.persist saves object with id 0

Hello list,

Thanks for all the replies :)

I've actually created the entities and the xml + annotations mappings using the 
eclipse hibernate plugin, I've just added the tapestry annotations.

For example for the user entity:

http://dpaste.com/205037/

Hibernate xml mapping file:

http://dpaste.com/205038/

CRUD code:
@Inject
Session session

@Component
private Usuario _user;

@CommitAfter
Object onSuccess()
{
try {
   session.persist(_user);
}
catch (RuntimeException e) {
throw e;
}
return this;
}

thank you people!

greetings,

Genis


Al 08/06/2010 14:35, En/na Everton Agner ha escrit:
> And I forgot to mention it...
> 
> Yes, the @CommitAfter annotation tells Tapestry to wrap that method in a 
> Transaction when it will call it... So, is enough to just .persist() it. ;)
> 
> 
> *De:* Everton Agner 
> *Para:* Tapestry users ; gpu...@ngeografics.com
> *Enviadas:* Terça-feira, 8 de Junho de 2010 9:32:36
> *Assunto:* Res: session.persist saves object with id 0
> 
> Could you show us how you mapped your Entity?** And regardless if it was by 
> XML or Annotations, show your Entity class code too.*
> 
> 
> De:* Peter Stavrinides 
> *Para:* Tapestry users ; gpu...@ngeografics.com
> *Enviadas:* Terça-feira, 8 de Junho de 2010 5:39:14
> *Assunto:* Re: session.persist saves object with id 0
> 
> Perhaps the type is a primitive, so instead of null a default value will be 
> 0? just a guess.
> 
> Peter
> 
> 
> - Original Message -
> From: "Genís Pujol" mailto:gpu...@ngeografics.com>>
> To: "Tapestry users"  <mailto:users@tapestry.apache.org>>
> Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest, 
> Istanbul
> Subject: session.persist saves object with id 0
> 
> Hello,
> 
> After checking the tutorial I was trying to do a basic crud app, but
> somehow after submiting the form (beaneditform) the new object is saved
> into the database with id 0.
> 
> I'm also new to hibernate so I don't know why in the tapestry tutorial
> is enough with session.persist(object), what happened to the factory,
> session.commit, session.close and the Transaction object? is that all
> included with the @CommitAfter annotation?
> 
> 
> Any idea why a new object would be saved with id 0?
> 
> regards,
> 
> Genis
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
> <mailto:users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org 
> <mailto:users-h...@tapestry.apache.org>
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
> <mailto:users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org 
> <mailto:users-h...@tapestry.apache.org>
> 
> 
> 


  

Re: Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Thiago H. de Paula Figueiredo
On Wed, 09 Jun 2010 09:16:55 -0300, Everton Agner  
 wrote:


I'm not a Hibernate advanced user, but you're using a XML and Entity  
class annotations to configure your Entity?


I haven't noticed that. Ewerton is right: no need to use XML mappings when  
you use annotations.


Anyways... If you want your app to automatically increment your ID  
before saving it, you shouldn't use the:


In this case, it isn't the app the increments the ID, the database does.


   


Or @GeneratedValue.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Res: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Everton Agner
I'm not a Hibernate advanced user, but you're using a XML and Entity class 
annotations to configure your Entity?

Anyways... If you want your app to automatically increment your ID before 
saving it, you shouldn't use the:



That tells hibernate that you want to programatically set the ID.

I guess you should use...



...instead. Try it out, i guess it will work.


- Everton




De: Genís Pujol 
Para: Tapestry users 
Enviadas: Quarta-feira, 9 de Junho de 2010 4:12:31
Assunto: Re: Res: Res: session.persist saves object with id 0

Hello list,

Thanks for all the replies :)

I've actually created the entities and the xml + annotations mappings using the 
eclipse hibernate plugin, I've just added the tapestry annotations.

For example for the user entity:

http://dpaste.com/205037/

Hibernate xml mapping file:

http://dpaste.com/205038/

CRUD code:
@Inject
Session session

@Component
private Usuario _user;

@CommitAfter
Object onSuccess()
{
try {
   session.persist(_user);
}
catch (RuntimeException e) {
throw e;
}
return this;
}

thank you people!

greetings,

Genis


Al 08/06/2010 14:35, En/na Everton Agner ha escrit:
> And I forgot to mention it...
> 
> Yes, the @CommitAfter annotation tells Tapestry to wrap that method in a 
> Transaction when it will call it... So, is enough to just .persist() it. ;)
> 
> 
> *De:* Everton Agner 
> *Para:* Tapestry users ; gpu...@ngeografics.com
> *Enviadas:* Terça-feira, 8 de Junho de 2010 9:32:36
> *Assunto:* Res: session.persist saves object with id 0
> 
> Could you show us how you mapped your Entity?** And regardless if it was by 
> XML or Annotations, show your Entity class code too.*
> 
> 
> De:* Peter Stavrinides 
> *Para:* Tapestry users ; gpu...@ngeografics.com
> *Enviadas:* Terça-feira, 8 de Junho de 2010 5:39:14
> *Assunto:* Re: session.persist saves object with id 0
> 
> Perhaps the type is a primitive, so instead of null a default value will be 
> 0? just a guess.
> 
> Peter
> 
> 
> - Original Message -
> From: "Genís Pujol" mailto:gpu...@ngeografics.com>>
> To: "Tapestry users"  <mailto:users@tapestry.apache.org>>
> Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest, 
> Istanbul
> Subject: session.persist saves object with id 0
> 
> Hello,
> 
> After checking the tutorial I was trying to do a basic crud app, but
> somehow after submiting the form (beaneditform) the new object is saved
> into the database with id 0.
> 
> I'm also new to hibernate so I don't know why in the tapestry tutorial
> is enough with session.persist(object), what happened to the factory,
> session.commit, session.close and the Transaction object? is that all
> included with the @CommitAfter annotation?
> 
> 
> Any idea why a new object would be saved with id 0?
> 
> regards,
> 
> Genis
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
> <mailto:users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org 
> <mailto:users-h...@tapestry.apache.org>
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
> <mailto:users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org 
> <mailto:users-h...@tapestry.apache.org>
> 
> 
> 


  

Re: Res: Res: session.persist saves object with id 0

2010-06-09 Thread Genís Pujol

Hello list,

Thanks for all the replies :)

I've actually created the entities and the xml + annotations mappings 
using the eclipse hibernate plugin, I've just added the tapestry 
annotations.


For example for the user entity:

http://dpaste.com/205037/

Hibernate xml mapping file:

http://dpaste.com/205038/

CRUD code:
@Inject
Session session

@Component
private Usuario _user;

@CommitAfter
Object onSuccess()
{
try {
   session.persist(_user);
}
catch (RuntimeException e) {
throw e;
}
return this;
}

thank you people!

greetings,

Genis


Al 08/06/2010 14:35, En/na Everton Agner ha escrit:

And I forgot to mention it...

Yes, the @CommitAfter annotation tells Tapestry to wrap that method in 
a Transaction when it will call it... So, is enough to just .persist() 
it. ;)



*De:* Everton Agner 
*Para:* Tapestry users ; gpu...@ngeografics.com
*Enviadas:* Terça-feira, 8 de Junho de 2010 9:32:36
*Assunto:* Res: session.persist saves object with id 0

Could you show us how you mapped your Entity?** And regardless if it 
was by XML or Annotations, show your Entity class code too.*



De:* Peter Stavrinides 
*Para:* Tapestry users ; gpu...@ngeografics.com
*Enviadas:* Terça-feira, 8 de Junho de 2010 5:39:14
*Assunto:* Re: session.persist saves object with id 0

Perhaps the type is a primitive, so instead of null a default value 
will be 0? just a guess.


Peter


- Original Message -
From: "Genís Pujol" <mailto:gpu...@ngeografics.com>>
To: "Tapestry users" <mailto:users@tapestry.apache.org>>
Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul

Subject: session.persist saves object with id 0

Hello,

After checking the tutorial I was trying to do a basic crud app, but
somehow after submiting the form (beaneditform) the new object is saved
into the database with id 0.

I'm also new to hibernate so I don't know why in the tapestry tutorial
is enough with session.persist(object), what happened to the factory,
session.commit, session.close and the Transaction object? is that all
included with the @CommitAfter annotation?


Any idea why a new object would be saved with id 0?

regards,

Genis

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
<mailto:users-unsubscr...@tapestry.apache.org>
For additional commands, e-mail: users-h...@tapestry.apache.org 
<mailto:users-h...@tapestry.apache.org>



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org 
<mailto:users-unsubscr...@tapestry.apache.org>
For additional commands, e-mail: users-h...@tapestry.apache.org 
<mailto:users-h...@tapestry.apache.org>








Re: Res: session.persist saves object with id 0

2010-06-08 Thread Dmitry Gusev
Just to clarify, if you're talking about tynamo's tapestry-jpa module then:

@CommitAfter tells Tapestry to commit after this method successfully
completed.
Initially the transaction created automatically in the beginning of each
request processing (and rolled back if you haven't declare any @CommitAfter
annotation).
Right after the commit new transaction will be created (and again, it will
be rolled back at the end of request processing if you haven't declare any
@CommitAfter annotation).

On Tue, Jun 8, 2010 at 16:35, Everton Agner wrote:

> And I forgot to mention it...
>
> Yes, the @CommitAfter annotation tells Tapestry to wrap that method in a
> Transaction when it will call it... So, is enough to just .persist() it. ;)
>
>
>
>
> 
> De: Everton Agner 
> Para: Tapestry users ; gpu...@ngeografics.com
> Enviadas: Terça-feira, 8 de Junho de 2010 9:32:36
> Assunto: Res: session.persist saves object with id 0
>
>
> Could you show us how you mapped your Entity? And regardless if it was by
> XML or Annotations, show your Entity class code too.
>
>
> De: Peter Stavrinides 
> Para: Tapestry users ; gpu...@ngeografics.com
> Enviadas: Terça-feira, 8 de Junho de 2010 5:39:14
> Assunto: Re: session.persist saves object with id 0
>
> Perhaps the type is a primitive, so instead of null a default value will be
> 0? just a guess.
>
> Peter
>
>
> - Original Message -
> From: "Genís Pujol" 
> To: "Tapestry users" 
> Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest,
> Istanbul
> Subject: session.persist saves object with id 0
>
> Hello,
>
> After checking the tutorial I was trying to do a basic crud app, but
> somehow after submiting the form (beaneditform) the new object is saved
> into the database with id 0.
>
> I'm also new to hibernate so I don't know why in the tapestry tutorial
> is enough with session.persist(object), what happened to the factory,
> session.commit, session.close and the Transaction object? is that all
> included with the @CommitAfter annotation?
>
>
> Any idea why a new object would be saved with id 0?
>
> regards,
>
> Genis
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>
>
>



-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Res: Res: session.persist saves object with id 0

2010-06-08 Thread Everton Agner
And I forgot to mention it...

Yes, the @CommitAfter annotation tells Tapestry to wrap that method in a 
Transaction when it will call it... So, is enough to just .persist() it. ;)





De: Everton Agner 
Para: Tapestry users ; gpu...@ngeografics.com
Enviadas: Terça-feira, 8 de Junho de 2010 9:32:36
Assunto: Res: session.persist saves object with id 0


Could you show us how you mapped your Entity? And regardless if it was by XML 
or Annotations, show your Entity class code too.


De: Peter Stavrinides 
Para: Tapestry users ; gpu...@ngeografics.com
Enviadas: Terça-feira, 8 de Junho de 2010 5:39:14
Assunto: Re: session.persist saves object with id 0

Perhaps the type is a primitive, so instead of null a default value will be 0? 
just a guess.

Peter


- Original Message -
From: "Genís Pujol" 
To: "Tapestry users" 
Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: session.persist saves object with id 0

Hello,

After checking the tutorial I was trying to do a basic crud app, but 
somehow after submiting the form (beaneditform) the new object is saved 
into the database with id 0.

I'm also new to hibernate so I don't know why in the tapestry tutorial  
is enough with session.persist(object), what happened to the factory, 
session.commit, session.close and the Transaction object? is that all 
included with the @CommitAfter annotation?


Any idea why a new object would be saved with id 0?

regards,

Genis

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


  

Res: session.persist saves object with id 0

2010-06-08 Thread Everton Agner
Could you show us how you mapped your Entity? And regardless if it was by XML 
or Annotations, show your Entity class code too.


De: Peter Stavrinides 
Para: Tapestry users ; gpu...@ngeografics.com
Enviadas: Terça-feira, 8 de Junho de 2010 5:39:14
Assunto: Re: session.persist saves object with id 0

Perhaps the type is a primitive, so instead of null a default value will be 0? 
just a guess.

Peter


- Original Message -
From: "Genís Pujol" 
To: "Tapestry users" 
Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: session.persist saves object with id 0

Hello,

After checking the tutorial I was trying to do a basic crud app, but 
somehow after submiting the form (beaneditform) the new object is saved 
into the database with id 0.

I'm also new to hibernate so I don't know why in the tapestry tutorial  
is enough with session.persist(object), what happened to the factory, 
session.commit, session.close and the Transaction object? is that all 
included with the @CommitAfter annotation?


Any idea why a new object would be saved with id 0?

regards,

Genis

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


  

Re: session.persist saves object with id 0

2010-06-08 Thread Peter Stavrinides
Perhaps the type is a primitive, so instead of null a default value will be 0? 
just a guess.

Peter


- Original Message -
From: "Genís Pujol" 
To: "Tapestry users" 
Sent: Tuesday, 25 May, 2010 18:30:10 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: session.persist saves object with id 0

Hello,

After checking the tutorial I was trying to do a basic crud app, but 
somehow after submiting the form (beaneditform) the new object is saved 
into the database with id 0.

I'm also new to hibernate so I don't know why in the tapestry tutorial  
is enough with session.persist(object), what happened to the factory, 
session.commit, session.close and the Transaction object? is that all 
included with the @CommitAfter annotation?


Any idea why a new object would be saved with id 0?

regards,

Genis

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



session.persist saves object with id 0

2010-05-25 Thread Genís Pujol

Hello,

After checking the tutorial I was trying to do a basic crud app, but 
somehow after submiting the form (beaneditform) the new object is saved 
into the database with id 0.


I'm also new to hibernate so I don't know why in the tapestry tutorial  
is enough with session.persist(object), what happened to the factory, 
session.commit, session.close and the Transaction object? is that all 
included with the @CommitAfter annotation?



Any idea why a new object would be saved with id 0?

regards,

Genis

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org