On 2013-04-03 21:07, Vadim Lopatin wrote:
I don't see what to simplify in markup like this:

     @Entity
     class User {

         @Generated
         long id;

         @Column
         string name;

         @ManyToOne
         Customer customer;

         @ManyToMany
         LazyCollection!Role roles;
     }

Which translates to table definitions like
CREATE TABLE user (id bigint not null primary key auto_increment, name
varchar(255), customer_fk bigint foreign key references customer(id));
CREATE TABLE user_roles (user_fk bigint not null foreign key references
user(id), role_fk int not null foreign key references role(id), primary
key(user_fk, role_fk);
...

Is the attributes necessary at all? I would just go with:

class User
{
long id; // always assume auto increment, primary key, not null and so on
    string name;
    Customer customer; // infer @ManyToOne
@ManyToMany LazyCollection!Role roles; // I guess this cannot be inferred
    LazyCollection!Foo foos; // infer @OneToMany
}

Perhaps for primitive types you could have:

class User
{
    Long id;
    String name;
    Int foo;
}

Note the capital letters.

--
/Jacob Carlborg

Reply via email to