Note that there are some explanatory texts on larger screens.

plurals
  1. POorg.springframework.data.mapping.PropertyReferenceException: No property catch found for type
    text
    copied!<p>I hope you can help me, I have a issue with <em>Spring Data</em> repositories.</p> <p>When I deploy I get an exception and it is due because <em>Spring Dat</em>a try to derive dinamically the method, but can't find in the Entity the corresponding property.</p> <p>Can you help me? How can I put a custom method in the Custom Repository without this issue? Thank you very much in advance!</p> <p>Andrea</p> <p>These are the involved components:</p> <ol> <li><code>LocaleJpaImpl</code>: the Entity</li> <li><code>LocaleJpaRepositoryClient</code>: the business layer class</li> <li><code>interface LocaleJpaRepository extends JpaRepository&lt;LocaleJpaImpl, Long&gt;, LocaleJpaRepositoryCustom</code></li> <li><code>interface LocaleJpaRepositoryCustom</code></li> <li><code>LocaleJpaRepositoryImplemented implements LocaleJpaRepositoryCustom</code></li> </ol> <p><code>LocaleJpaRepositoryCustom</code> has a method: </p> <pre><code>List&lt;String&gt; catchLanguagesCombinations() throws DAOSystemException; </code></pre> <p>(LanguagesCombinations isn't a property of LocaleJpaImpl. For that motive is in the Custom Repository).</p> <p>This exception:</p> <pre><code>Caused by: org.springframework.data.mapping.PropertyReferenceException: No property languages found for type com.engine.i18n.domain.LocaleJpaImpl at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:74) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:326) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:306) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:244) at org.springframework.data.repository.query.parser.Part.&lt;init&gt;(Part.java:73) at org.springframework.data.repository.query.parser.PartTree$OrPart.&lt;init&gt;(PartTree.java:180) at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260) at org.springframework.data.repository.query.parser.PartTree$Predicate.&lt;init&gt;(PartTree.java:240) at org.springframework.data.repository.query.parser.PartTree.&lt;init&gt;(PartTree.java:68) at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:57) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:280) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ... 33 more </code></pre> <hr> <p>This is the relevant code:</p> <p><strong>1. LocaleJpaImpl:</strong></p> <pre><code>import java.io.Serializable; import javax.persistence.AttributeOverride; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; import com.jpa.BaseEntityJpaSupport; @Entity @Table(name = "LOCALE") @XmlRootElement @AttributeOverride(name="id", column=@Column(name="LOCALE_ID")) @NamedQueries({ @NamedQuery(name = "Locale.findAll", query = "FROM LocaleJpaImpl l"), @NamedQuery(name = "Locale.findByLocaleId", query = "FROM LocaleJpaImpl l WHERE l.localeId = :localeId"), @NamedQuery(name = "Locale.findByLanguageCode", query = "FROM LocaleJpaImpl l WHERE l.languageCode = :languageCode") public class LocaleJpaImpl extends BaseEntityJpaSupport implements Serializable { private static final long serialVersionUID = 1L; //@Id //@Column(name = "LOCALE_ID") @Basic(optional = false) @NotNull @GeneratedValue(strategy = GenerationType.AUTO) private Integer localeId; @Size(max = 2) @Column(name = "LANGUAGE_CODE") private String languageCode; public LocaleJpaImpl(Integer localeId) { this.localeId = localeId; } public int getLocaleId() { return localeId; } public void setLocaleId(Integer localeId) { this.localeId = localeId; } public String getLanguageCode() { return languageCode; } public void setLanguageCode(String languageCode) { this.languageCode = languageCode; } } </code></pre> <p><strong>3. interface LocaleJpaRepository</strong></p> <pre><code>import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import com.engine.i18n.domain.LocaleJpaImpl; public interface LocaleJpaRepository extends JpaRepository&lt;LocaleJpaImpl, Long&gt;, LocaleJpaRepositoryCustom { @Query("FROM LocaleJpaImpl L WHERE L.languageCode = :languageCode") List&lt;LocaleJpaImpl&gt; findLocaleByLanguageCode(@Param("languageCode") String languageCode); } </code></pre> <p><strong>4. interface LocaleJpaRepositoryCustom</strong></p> <pre><code>import java.util.List; import com.util.DAOSystemException; public interface LocaleJpaRepositoryCustom { List&lt;String&gt; catchLanguagesCombinations() throws DAOSystemException; } </code></pre> <p><strong>5. LocaleJpaRepositoryImplemented</strong></p> <pre><code>import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import com.util.DAOSystemException; public class LocaleJpaRepositoryImplemented implements LocaleJpaRepositoryCustom { @PersistenceContext(unitName = "contentEntityManagerFactory") private EntityManager em; @SuppressWarnings("unchecked") @Override public List&lt;String&gt; catchLanguagesCombinations() throws DAOSystemException { return "result"; } } </code></pre> <p>Thank you for your attention till here. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload