내 데이터베이스 테이블에 합류했다.봄 최대 절전 모드 액세스 데이터베이스 필드를
public Weather getWeatherById(Integer id) {
return (Weather) sessionFactory.getCurrentSession().get(Weather.class, id);
}
컨트롤러 :
model.addAttribute("weather", weatherService.getWeatherById(id));
질문 - 그래서 이것은 컨트롤러에 반환됩니다, JSP로 전송
@Entity
@Table(name="CITIES")
public class City {
@Id
@Column(name="ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "CITIES_ID_SEQ")
@SequenceGenerator(name = "CITIES_ID_SEQ", sequenceName="cities_id_seq", allocationSize=1)
private Integer id;
@Column(name="NAME")
private String name;
//here come getters and setters
DAO 예를 City.java에 대한
그렇다면 JSP에서cities.name
에 어떻게 액세스 할 수 있습니까? 아니면 특별한 쿼리 없이는 불가능합니다.
은 날씨 추상화의 도시의 일부인가? 그렇다면 거기에 액세스 할 수 있으며 거기에서 이름을 얻을 수 있습니다. – mkro
@mkro : 추상화에서의 의미는 무엇입니까? – Jaanus
@ danny.lesnik의 대답은 다음과 같습니다 : 날씨 정보에 대한 수업이 필요하며 그 수업은 도시와 연결되어야합니다. – mkro