This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Generated Value Strategy

 
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?
 
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
Boost this thread!