Results 1 to 2 of 2

Thread: Extending existing roo entities

  1. #1

    Default 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. #2
    Join Date
    Jun 2008
    Location
    Philadelphia, PA, USA
    Posts
    212

    Default

    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
    Ken Rimple
    Chariot Solutions
    email: krimple@chariotsolutions.com
    work: www.chariotsolutions.com/education
    personal: www.rimple.com

    Author: Spring Roo in Action (Manning)
    MEAP Site: manning.com/rimple

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •