Created
April 4, 2011 19:05
-
-
Save huljas/902204 to your computer and use it in GitHub Desktop.
SimpleEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class SimpleEntity extends Model { | |
public String name; | |
public int age; | |
public boolean isEternal; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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