Announcement Announcement Module
Collapse
No announcement yet.
Did the default key generation mode change in 1.1.0? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Did the default key generation mode change in 1.1.0?

    I have a question related to some work I did on chapter 4 of Roo in Action...

    A forum poster in the Manning forum showed me how a test was failing. I had set up an inheritance hierarchy using TABLE_PER_CLASS in that chapter, back in Roo 1.0.0. The key generation in the _Roo_Entity.aj file was:

    Code:
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id")
    private Long BaseTask.id;
    The table key type generation worked. However, on Roo 1.1.0, the key generation is this (which causes it to fail on databases with the IDENTITY key generation strategy):

    Code:
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long BaseTask.id;
    This fails due to the fact that Hibernate won't support IDENTITY primary generation support for the TABLE_PER_CLASS inheritance heirarchy type. I would think this is a potential problem in the mapping strategy, because it doesn't work the same across all database types. Am I wrong here, or is this a subtle bug?

    I was able to work around it by implementing my own Primary Key and getter/setter in the class file itself, using the Hibernate SEQUENCE generation strategy, and running Roo to remove them from the aspects. It fixes it on Hypersonic SQL:

    Code:
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id")
    private Long id;
        
    public Long getId() {
        return id;
    }
        
    public void setId(Long id) {
       this.id = id;
    }
    Any ideas? I want to make sure I'm suggesting the right approach and that things indeed changed.

    Best,

    Ken
Working...
X