@Entity注記
5581 ワード
[@Entity]
@Id
No identifier specified for entity:
name
( ) 。 。
。
Java 。
@Table SnakeCaseStrategy( )
name @Table name SnakeCaseStrategy( )
:
@Entity
public class UserEntity{...} user_entity
@Entity(name="UE")
public class UserEntity{...} ue
@Entity(name="UsEntity")
public class UserEntity{...} us_entity
package sun.rain.amazing.javax.anno.domain;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
/**
* @author sunRainAmazing
*/
@Entity
@Data
public class UserEntity {
/**
* No identifier specified for entity: sun.rain.amazing.javax.anno.domain.UserEntity
*/
@Id
private int id;
private String username;
private String email;
public UserEntity(String username, String email) {
this.username = username;
this.email = email;
}
public UserEntity() {
}
}
CREATE TABLE `user_entity` (
`id` int(11) NOT NULL,
`email` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
package sun.rain.amazing.javax.anno.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
*
* @author sunRainAmazing
*/
@Data
@AllArgsConstructor
@Entity(name="UePro")
public class UserEntityProperty {
/**
* No identifier specified for entity: sun.rain.amazing.javax.anno.domain.UserEntity
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String email;
private String mobile;
public UserEntityProperty(String username, String email, String mobile) {
this.username = username;
this.email = email;
this.mobile = mobile;
}
public UserEntityProperty() {
}
}
CREATE TABLE `ue_pro` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) DEFAULT NULL,
`mobile` varchar(255) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8