Announcement Announcement Module
Collapse
No announcement yet.
Extending existing roo entities Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending existing roo entities

    Hi,
    my second post in a day, apologies for spam. Hopefully somebody will know ...
    I have a big roo project in production for quite a long time.
    Now I am facing problem with tables becoming huge. Since I do not need to keep data older than 3 months, I am thinking about moving data from "active" tables into archive tables in some batch nightly process.

    I use
    Code:
      @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "id")
    as id in my entities.

    Now, the question is: what is the best way to create the copies of the entities which differ only at Id, since IDs need to be the same as in "active" tables, I can't use JPA annotation, but set ids manually.

    By "the best", I mean:
    - minor to no change in existing entities,
    - little repetition (avoiding copy paste) in archive entities.
    - no change in existing db tables.

    Thanks in advance,
    Milan


    Thanks

  • #2
    Do you want to clone entity instances? i.e. if you have an instance with id of 123, you want to create a new one, and insert it into the database with all of the properties of 123 but the key (which would be auto generated perhaps?)

    Why not implement Cloneable? Also SpringUtils or some class like that has a copyProperties() method that you can use to copy all properties (and I think it can take a white/blacklist). So you could just use that to clone it. Then you could do a save.

    Ken

    Comment

    Working...
    X