facebook

Scaffolding Crud using a self referenced Table

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #314364 Reply

    Peter
    Member

    Hi,

    I have a database with many self referencing tables, using one-many relationship i.e.

    CREATE TABLE account
    (
    id integer NOT NULL,
    referenceno character varying(10) NOT NULL,
    createdate timestamp without time zone NOT NULL,
    timezone character varying(40) NOT NULL,
    status smallint NOT NULL,

    account_upper_id integer,
    CONSTRAINT “PK153” PRIMARY KEY (id),
    CONSTRAINT “Refaccount492” FOREIGN KEY (account_upper_id)
    REFERENCES account (id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION,
    )

    When i scaffold a crud application from this database everything seems fine other than when it generates services/controllers .e.g. it creates this service method

    public Account deleteAccountAccount(Integer account_id) {
    Account account = accountDAO.findAccountByPrimaryKey(account_id, -1, -1);
    Account account = accountDAO.findAccountByPrimaryKey(account_id, -1, -1);

    account.setAccount(null);
    account.setAccounts(null);
    account = accountDAO.store(account);
    accountDAO.flush();

    account = accountDAO.store(account);
    accountDAO.flush();

    accountDAO.remove(account);
    accountDAO.flush();

    return account;
    }

    It has 2 Account variables with the same name.
    This causes build errors in many methods and services. Please help it will take me way too long to go around changing all of them.

    Thanks!

    #314692 Reply

    jkennedy
    Member

    This issue is being corrected in MyEclipse for Spring 9.0.

    Moving forward the variable names will be based on the relationship name rather than the name of the Entity.

    Thanks,
    Jack

    #314711 Reply

    Peter
    Member

    Hi Jack!

    Thanks so much for your reply!!!

    When will MEfS 9.0 be released?

    What do you by your second sentence? I’m sorry I am new to this. I don’t understand whether thats something i could do to remedy the problem now or whether that is what will be fixed in the next release. If thats something i could do, can you provide some more details please?

    thanks again!

    #314776 Reply

    jkennedy
    Member

    Hello,
    The release of MyEclipse for Spring 9.0 is close, we are working on an exact release date and will try to update the community as soon as possible.

    Regarding my second sentence, one of the issues with self relationships in our scaffolding was based on the naming conventions of the inputs and the variable names used in the methods. By default we were using the name of the Entity to name variables which was fine, as long as you didn’t have a method that was managing a relationship that pointed back to the same entity. When this happened, our default naming strategy generated duplicate variable names.
    And so where you may have had a method that should have read: setEmployeeManager (Employee employee, Employee manager) we would instead end up with a method that read: setEmployeeManager (Employee employee, Employee employee) or similar.

    And so you could certainly correct the code that was generated by hand to eliminate the compile errors by using appropriate variable names and the rest should work correctly.

    Hope that helps, thanks again.
    Jack

    #314857 Reply

    Peter
    Member

    Jack!

    Thanks for that! My data model is quite large it will take a very long time for me to change all the services. So I think i will wait for v9…very exciting to here about JSF and PrimeFaces also!

    Thanks again jack!

    Peter

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Scaffolding Crud using a self referenced Table

You must be logged in to post in the forum log in