Results 1 to 2 of 2

Thread: how roo create table with cascade in mysql

  1. #1
    Join Date
    Dec 2009
    Posts
    11

    Default how roo create table with cascade in mysql

    I am trying to have roo create two tables

    Users
    id
    username
    password

    UserRoles
    id
    roleName

    here is my syntax:
    entity --name ~.domain.UserRoles --testAutomatically
    field string roleName --notNull

    entity --name ~.domain.Users --testAutomatically
    field string userName --notNull
    field string password --notNull
    field set --fieldName roles --element ~.domain.UserRoles --class ~domain.Users --fetch EAGER

    as the result, it created
    1) users table with user_name, password
    2) user_roles with role_name
    3) users_roles with "users -> references _id field from users table", "roles -> references _id field from user_roles table"

    My question is that is there any way to create cascading delete/update, because from above roo commands, roo only creates "On Delete -> Restrict, On Update -> Restrict", I want to create "On Delete -> Cascade, On Update -> Cascade".

    I am using MySQL.

    thanks a lot!

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    The Roo annotation emitted is:

    Code:
        @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
        private Set<UserRoles> roles = new HashSet<UserRoles>();
    You are able to edit this annotation or add new ones. However without looking into it fully, I suspect what you're seeing is a limitation in the JPA to DB DDL conversion process.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Posting Permissions

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