Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generated Value Strategy

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am learning JPA from book Pro JPA 2- and I have a doubt in the topic - ID Generation using the Table
My doubt is regarding @TableGenerator
When I used


it behaved like AUTO strategy.(Did it happen because I missed the strategy? But no such mention in the book :S)

When I gave the table name as below:

it still behaved like AUTO, even though I have the table this time in my database as

+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id_gen | varchar(100) | NO | PRI | | |
| key_value | int(11) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+

Please clarify as the behavior is not clear to me.
I came across this while trying to code the examples in the book and when they did not work as expected (Used Hibernate and MySQL) .

Please help me with the problem and let me know if further details required.

Thanks
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any replies?
I think I have provided the complete details, still if further information required please reply.

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is my question missing any details?
If not, why no answers yet?
 
Rafael de Sousa
Greenhorn
Posts: 12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sudhanshu Mishra,

Although you created a valid generator, you still need to override the default generation strategy, as follows:



There's no need for pushing anyone for answers, alright?!
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,Rafael de Sousa
If you read the question completly, I also referred that it was mentioned in the Pro JPA 2 book.
Thanks for helping me get this straight though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic