Results 1 to 6 of 6

Thread: Spring Roo DBRE Primary Key Insert / Update (asked on stackoverflow, needs answer)

  1. #1
    Join Date
    Nov 2008
    Posts
    25

    Default Spring Roo DBRE Primary Key Insert / Update (asked on stackoverflow, needs answer)

    The following question, which I also have, is on stackoverflow

    I am creating an application with Spring Roo. When I do a reverse engineer on a database table everything looks great but there are no fields for the primary keys, which are in the database. These are not auto incrementing but rather need to be filled manually or are drive off another table. When I launch my spring roo application I can create or view the tables and their fields but I can'r see primary key anywhere to view or update. Any advice on how to accomplish this?
    the stackoverflow link

  2. #2
    Join Date
    Nov 2008
    Posts
    25

    Default

    Anyone have an answer?

  3. #3
    Join Date
    Dec 2005
    Posts
    935

    Default

    What do you mean there are no fields? Are there xxx_Roo_Identififer ITDs present ?
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  4. #4
    Join Date
    Nov 2008
    Posts
    25

    Default

    For example I have a Documenttype_Roo_Jpa_Entity.aj file at end which was created by DBRE

    Since the Id is a String, I want to supply it manually in the Web interface. How can I tell Roo/Spring that it should include an input field in the generated web layer such that I can supply it manually? I assume since this is the Id/PK Roo thinks that this is generated automatically and therefore does not need to be editable on the web layer, however in my case (and the persons on stackoverflow) we need to provide it manually, and need it exposed and editable in the web layer.

    Please note that the Entity.aj file contains this Id field but not in the DbManaged.aj file. (I am mentioning in case this matters.)

    Thanks in advance.


    privileged aspect Documenttype_Roo_Jpa_Entity {

    declare @type: Documenttype: @Entity;

    declare @type: Documenttype: @Table(name = "documenttype");

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "documentTypeCd", columnDefinition = "CHAR", length = 4)
    private String Documenttype.documentTypeCd;

    public String Documenttype.getDocumentTypeCd() {
    return this.documentTypeCd;
    }

    public void Documenttype.setDocumentTypeCd(String id) {
    this.documentTypeCd = id;
    }

    }
    Last edited by melutovich; Nov 21st, 2012 at 05:22 AM.

  5. #5
    Join Date
    Dec 2005
    Posts
    935

    Default

    The mvc latyer does not support the editing of primary keys unless the id is a composite key, in which you must enter values for.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  6. #6
    Join Date
    Nov 2008
    Posts
    25

    Default

    Thanks. Next second approach question:

    I've seen some where that I could add a @PrePersist method to set the PK/id, however that involved editing the Enity.aj file, which can get overridden, when I added it into the general .java file, it was not recognized, where should I place the @PrePersist method so that it is recognized and not overridden?

Tags for this Thread

Posting Permissions

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