我正在将spring数据jpa与hibernate和postgres一起使用。我正在尝试在列中保存一个整数数组。我正在使用vlad mihaceas库将数组持久化到postgresql中。实体如下:-
@Type(type = "int-array")
@Column(name = "location", columnDefinition = "integer[]")
private Integer[] locations;
对应的位置实体是
@Entity
@Table(name = "location_master")
public class Location implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "location_name")
private String locationName;
}
位置ID正在保存在数据库中。但是我无法在百里香叶中展示它。
<tr>
<td>Selected Locations</td>
<td>[[${office.locations[0].locationName}]]</td>
</tr>
出现以下错误:-
org.springframework.expression.spel.SpelEvaluationException:EL1008E: 在类型的对象上找不到属性或字段“ locationName” 'java.lang.Integer'-可能不公开或无效?
答案 0 :(得分:0)
org.springframework.expression.spel.SpelEvaluationException:EL1008E:在类型为'java.lang.Integer'的对象上找不到属性或字段'locationName'-可能不是公共的或无效的吗?
该错误与hibernate-types项目的WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait( 10, TimeUnit.SECONDS );
driver.get( "https://www.ticketmaster.com/review" );
driver.switchTo().frame("loginFrame");
WebElement inputElement = driver.findElement( By.id( "login-input" ) );
inputElement.sendKeys("test");
的使用无关。
该错误消息与您用于设置return dateFormat.parse(t2.getTaskDate()).compareTo(dateFormat.parse(t1.getTaskDate()));
的Spring Expression Language有关
这是int-array
属性。
locationName
String
属性是[[${office.locations[0].locationName}]]
,但是您将其视为locations
数组。
您想要的是Integer[]
Location
:
@OneToMany
还有List<Location>
中的一个@OneToMany(mappedBy="office", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Location> locations = new ArrayList<>();
关联:
@ManyToOne
查看this article,了解有关使用Location
关联的最佳方法的更多详细信息。