(yet another newbie using roo+hibernate)
The problem i had to deal with is the following...
I have created an abstract class Event and its Inheritance Strategy = TABLE_PER_CLASS.
And subclasses extending Event: Rating, Tagging.Code:@RooJavaBean @RooToString @RooJpaActiveRecord(inheritanceType = "TABLE_PER_CLASS") @RooJson public abstract class Event { ... }
Start the serverCode:@RooJavaBean @RooToString @RooJson @RooSolrSearchable @RooJpaActiveRecord(table = "ratings", finders = { "findRatingsByUser"}) public class Rating extends Event { ... }
Create Rating -> id = 1
Create Tagging -> id = 2
Restart the server
Create Rating -> id = 32768
Create Tagging -> id = 32769
Restart the server again
Create Rating -> id = 65536
Create Tagging -> id = 65537
Each time i restart the server the next generated id provided by hibernate starts from restart_time*32768.
After searching I found out that Hibernate caches a block of ids for performance issues, read this http://stackoverflow.com/questions/2...ationtype-tabl
Solution:
(Push in Id from *_Roo_Jpa_Entity.aj)
Set the allocationSize you prefer and any other param, but dont forget the performance issues.
In development mode it s ok to set it equal to 1
Proposal:Code:@RooJavaBean @RooToString @RooJpaActiveRecord(inheritanceType = "TABLE_PER_CLASS") @RooJson public abstract class Event { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator="generatorName") @TableGenerator(name="generatorName", allocationSize=1) @Column(name = "id") private Long id; ... }
Not sure but i think it would be helpful Roo to include TableGenerator in the *_Roo_Jpa_Entity.aj, in order the developer to be aware of such issues.
(Btw the default value of allocationSize in TableGenerator is 50)
Any comment(s) more than welcome!!
GK


Reply With Quote
