Skip to content

Instantly share code, notes, and snippets.

@huljas
Created April 4, 2011 19:05
Show Gist options
  • Save huljas/902204 to your computer and use it in GitHub Desktop.
Save huljas/902204 to your computer and use it in GitHub Desktop.
SimpleEntity.java
-- new table for simple entity
create table SimpleEntity (
id bigint not null auto_increment,
age integer not null,
isEternal bit not null,
name varchar(255),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- added category for the simple entity
create table SimpleCategory (
id bigint not null auto_increment,
age integer not null,
name varchar(255),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table SimpleEntity add column category_id bigint;
alter table SimpleEntity add index FK9F72C8559BDF44F0 (category_id),
add constraint FK9F72C8559BDF44F0 foreign key (category_id) references SimpleCategory (id);
@Entity
public class SimpleEntity extends Model {
public String name;
public int age;
public boolean isEternal;
}
@Entity
public class SimpleEntity extends Model {
public String name;
public int age;
public boolean isEternal;
@ManyToOne
public SimpleCategory category;
}
@Entity
public class SimpleCategory {
public String name;
public int age;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment