Spring 3、jpa、Eclipse リンク、Spring データにシンプルな webapp があります。(VMwareサーバーで)実行しようとすると、エラーが発生しました:
org.springframework.data.mapping.PropertyReferenceException: No property show found for type foo.domain.Catalog
実在物:
@Entity
@Table(name="catalog")
@NamedQuery(name="Catalog.findAll", query="SELECT c FROM Catalog c")
public class Catalog implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private String id;
private String adres;
private String opis;
private String tytul;
//bi-directional many-to-one association to Category
@ManyToOne
@JoinColumn(name="cname", referencedColumnName="name")
private Category category;
public Catalog() {
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getAdres() {
return this.adres;
}
public void setAdres(String adres) {
this.adres = adres;
}
public String getOpis() {
return this.opis;
}
public void setOpis(String opis) {
this.opis = opis;
}
public String getTytul() {
return this.tytul;
}
public void setTytul(String tytul) {
this.tytul = tytul;
}
public Category getCategory() {
return this.category;
}
public void setCategory(Category category) {
this.category = category;
}
インターフェース リポジトリ:
public interface KatalogRepository extends JpaRepository<Catalog, Long>{
@Query("select c from Catalog c left join fetch c.name")
public List<Catalog> showAll();
@Query("select c from Catalog c where c.tytul like %?1")
public Catalog findByTytul(String tytul);
@Query("select c from Category c")
public List<Category> showAllCategory();
@Query("select c from Category c where c.id =:id")
public Category findCategoryById(Long id);
}
多くの解決策を試しましたが、役に立ちませんでした。誰かが同様の問題を抱えていますか?手伝ってくれてありがとう。
私のdaoクラス:
@Repository
public class KatalogDAO {
@Autowired
KatalogRepository katalogRepository;
//@Autowired
//CategoryRepository categoryRepository;
@Transactional
public List<Catalog> showAllSites(){
return katalogRepository.showAll();
}
@Transactional
public void saveSite(Catalog catalog){
katalogRepository.saveAndFlush(catalog);
}
@Transactional
public Catalog showByTitle(String tytul){
return katalogRepository.findByTytul(tytul);
}
@Transactional
public List<Category> showAllCategory(){
return katalogRepository.showAllCategory();
}
@Transactional
public Category findCategoryById(Long id){
return katalogRepository.findCategoryById(id);
}
}
そしてエンドポイント:
@Component
public class CatalogEndpoint {
@Autowired
KatalogDAO katalogDAO;
public List<Catalog> showAllSites(){
return katalogDAO.showAllSites();
}
public void saveSite(Catalog catalog ){
katalogDAO.saveSite(catalog);
}
public Catalog getByTitle(String tytul){
return katalogDAO.showByTitle(tytul);
}
public List<Category> showCategory(){
return katalogDAO.showAllCategory();
}
public Category findCategoryById(Long id){
return katalogDAO.findCategoryById(id);
}
}