在Spring Boot中膨胀实体中的内部类

huangapple 未分类评论45阅读模式
英文:

Inflate inner class in entity in Spring Boot

问题

我有一个实体和连接的JPA存储库。我需要初始化主对象,这对我有用,但我不能膨胀主实体中的内部对象。例如:

SQL:

select id, latitude, longitude from user where id = 1;

结构:

@Entity
@Table(name="user")
class User {
    @Id
    Integer id;
    Location location = new Location();
    public static class Location {
        @Column(name="latitude")
        double latitude;
        @Column(name="longitude")
        double longitude;
    }
}
英文:

I've entity and connected JPA repository. I need init main object and it's work for me but I can't inflate inner object in main entity. For example:

SQL:

select id, latitude, longitude from user where id = 1;

Struct:

@Entity
@Table(name="user")
class User {
	@Id
	Integer id;
	Location location = new Location();
	public static class Location {
		@Column(name="latitude")
		double latitude;
		@Column(name="longitude")
		double longitude;
	}
}

huangapple
  • 本文由 发表于 2020年4月9日 15:47:23
  • 转载请务必保留本文链接:https://java.coder-hub.com/61116277.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定