下面是我的存储库,它扩展了spring数据jpa的JpaRepository
public interface GamesDetailsRepository extends JpaRepository<Game,Integer>{ }
和实体
@Entity
@Table(name="game")
public class Game implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Integer id;
@Column(name="code")
private String code;
@Column(name="name")
private String name;
@Column(name="description")
private String description;
@Column(name="url")
private String providerURL;
@Column(name="is_portrait")
private Boolean portrait;
@Column(name="image_url")
private String imageURL;
@Column(name="created_at",insertable = false, updatable = false)
private Timestamp createdAt;
@Column(name="modified_at",insertable = false, updatable = false)
private Timestamp modifiedAt;
@Column(name="is_active")
private Boolean active;
@Column(name="is_active_inflight")
private Boolean activeInflight;
@Column(name="is_blacklisted")
private Boolean blacklisted;
@Column(name="provider_id")
private Integer providerId;
@Column(name="position")
private Integer position;
/*@OneToOne(mappedBy="id")
@Column(name="provider_id")
private Provider provider;*/
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name="game_tag", joinColumns = @JoinColumn(name = "game_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "tag_id", referencedColumnName = "id"))
private Set<Tag> tags;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name="game_category", joinColumns = @JoinColumn(name = "game_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "category_id", referencedColumnName = "id"))
private Set<Category> categories;
/*public Provider getProvider() {
return provider;
}
public void setProvider(Provider provider) {
this.provider = provider;
}*/
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
但是当我在做的时候
Game game=gamesDetailsRepository.findOne(id);
结果数据未映射到我的实体,而我能够获取name,image_url等数据,但不能获取描述和provider_id等数据
这是我的mysql表格相同的
+--------------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+-------------------+-----------------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| code | varchar(45) | NO | MUL | NULL | |
| name | varchar(45) | YES | | NULL | |
| description | text | YES | | NULL | |
| url | varchar(256) | YES | | NULL | |
| is_portrait | tinyint(1) | YES | | NULL | |
| image_url | varchar(256) | YES | | NULL | |
| created_at | timestamp | YES | | CURRENT_TIMESTAMP | |
| modified_at | timestamp | YES | | NULL | on update CURRENT_TIMESTAMP |
| is_active | tinyint(1) | YES | | NULL | |
| is_active_inflight | tinyint(1) | YES | | NULL | |
| provider_id | int(11) | YES | MUL | NULL | |
| position | int(11) | YES | | 1 | |
| is_blacklisted | tinyint(1) | YES | | 0 | |
+--------------------+--------------+------+-----+-------------------+-----------------------------+
为什么只有一些列数据被映射到我的实体,而其他列数据则没有。 我已经检查了mysql表,数据存在于coloumn.Any建议?