I have a project that we are managing by models in back and front (angular-spring).
I made a personalized consultation, to bring me the data in the model, and it brings them well, but if I enter the capture form when trying to save them, it tells me that these fields do not exist.
I had to create the fields for the customized query), but JsonIgnore and Trancent do not work.
The query I did was:
@Query(nativeQuery = true, value = " " +
" SELECT " +
" personas.per_id AS per_id, " +
" personas.per_nombre AS per_nombre, " +
" personas.per_rss AS per_rss, " +
" personas.per_twitter AS per_twitter, " +
" personas.per_facebook AS per_facebook, " +
" personas.per_url AS per_url, " +
" personas.per_status AS per_status, "+
" personas.per_id_usr AS per_id_usr, " +
" personas.per_id_sec AS per_id_sec, " +
" (SELECT sum(fuentes.fnt_total_registros) FROM fuentes WHERE fuentes.per_id = personas.per_id) AS totalnoticia, " +
" (SELECT MAX(fuentes.fnt_fecha_scrap) FROM fuentes WHERE fuentes.per_id = personas.per_id ) AS ultimaactualizacion, " +
" personas.per_fecha_creacion AS per_fecha_creacion " +
" FROM " +
" personas " +
" WHERE " +
" personas.per_id_sec = :per_id_sec " +
" GROUP BY per_id ")
List<Persona> getPersonaByIndiceSectorial(@Param("per_id_sec") Integer per_id_sec);
My model is:
@JsonIgnore
private String totalnoticia;
@JsonIgnore
public String getTotalnoticia() {
return totalnoticia;
}
@JsonIgnore
private Date ultimaactualizacion;
@JsonIgnore
public Date getUltimaactualizacion() {
return ultimaactualizacion;
}
public Persona(){
super();
}
The error is as follows:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n / a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException (HibernateJpaDialect.java:261) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible (HibernateJpaDialect.java:244) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible (AbstractEntityManagerFactoryBean.java:491) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible (ChainedPersistenceExceptionTranslator.java:59) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary (DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke (PersistenceExceptionTranslationInterceptor.java:147)
If I put it as ignore when the results are ready, it returns the null values of the model, totalnoticia
and ultimaactualizacion
, but yes, I leave them as a model, as it is.
When I insert data, I get an error because it says that the columns totalregistros
and ultimaactualizacion
are not found in my table in the database.