userName
? Используйте связи таблиц (OneToMany, ManyToOne). Так вы получите доступ к сущности User
, и далее ко всем его полям. ...
@OneToMany(fetch = FetchType.LAZY)
private List<QueryParams> queryParams;
...
...
return testObject;
...
поставить строчку Hibernate.initialize(testObject.getQueryParams);
fetch = FetchType.LAZY
). Проблема в том, что связанный объект не загружается с базы данных (здесь вам нужно почитать про proxy-объекты в hibernate).Hibernate.initialize(Object obj)
@Entity
@Table(name = "users")
public class User implements Serializable {
@Id
@Column(name = "user_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "users_user_id_seq")
@SequenceGenerator(name = "users_user_id_seq",
sequenceName = "users_user_id_seq",
allocationSize = 1)
private long userId;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "login", nullable = false, unique = true)
private String login;
@Column(name = "password", nullable = false)
private String password;
@Column(name = "email", nullable = false, unique = true)
private String email;
@Column(name = "enabled", nullable = false)
private boolean isEnabled;
@Column(name = "reg_date", nullable = false)
private Date regDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "authority_id", nullable = false)
private Authority authority;
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
@JsonIgnore
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
@JsonSerialize(using = SqlDateSerializer.class)
public Date getRegDate() {
return regDate;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
public Authority getAuthority() {
return authority;
}
public void setAuthority(Authority authority) {
this.authority = authority;
}
@Override
public String toString() {
return "User details" +
"Id = " + getUserId() + "\n" +
"Name = " + getName() + "\n" +
"Login = " + getLogin() + "\n" +
"Email = " + getEmail() + "\n" +
"Enabled = " + isEnabled() + "\n" +
"Role = " + getAuthority().getAuthority().name() + "\n" +
"Registration date = " + getRegDate();
}
.addClass(MyClass.class)
, а configuration.addAnnotatedClass(Main.class)
. return buf ?: Unpooled.buffer()
imageRequest.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
super.onComplete(response);
vkPhotoArray = (VKPhotoArray) response.parsedModel;
int i = 0;
for (VKApiPhoto vkPhoto : vkPhotoArray) {
imageResIds[i] = vkPhoto.photo_130;
i++;
}
mAdapter = new ImageAdapter(getActivity());
final GridView mGridView = (GridView) layout.findViewById(R.id.image_grid);
mGridView.setAdapter(mAdapter);
}
});