Skip to content
Advertisement

Using the concept of JPA, how to update table using data from another table?

FmoReorgGeo.java

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="fmo_reorg_geos")
public class FmoReorgGeo {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="ID")
    private Integer ID;
    
    @Column(name="F_AOI", nullable = false)
    private String fAoi;
    
    @Column(name="F_AG", nullable = false)
    private String fAg;
    
    @Column(name="F_RA", nullable = false)
    private String fRa;
    
    @Column(name="T_AOI", nullable = false)
    private String tAoi;
    
    @Column(name="T_AG", nullable = false)
    private String tAg;
    
    @Column(name="T_RA", nullable = false)
    private String tRa;
    
    @Column(name="CLLI", nullable = false)
    private String clli;
    
    @Column(name="TURF", nullable = false)
    private String turf;

    @Column(name="REGION", nullable = false)
    private String region;
    
    @Column(name="F_AOI_RID")
    private String fAoiRid;
    
    @Column(name="F_AG_RID")
    private String fAgRid;
    
    @Column(name="F_RA_RID")
    private String fRaRid;
    
    @Column(name="T_AOI_RID")
    private String tAoiRid;
    
    @Column(name="T_AG_RID")
    private String tAgRid;
    
    @Column(name="T_RA_RID")
    private String tRaRid;
 
    @Column(name="REORG_DT")
    private Date reorgDt;

    public Integer getID() {
        return ID;
    }

    public void setID(Integer iD) {
        ID = iD;
    }

    public String getfAoi() {
        return fAoi;
    }

    public void setfAoi(String fAoi) {
        this.fAoi = fAoi;
    }

    public String getfAg() {
        return fAg;
    }

    public void setfAg(String fAg) {
        this.fAg = fAg;
    }

    public String getfRa() {
        return fRa;
    }

    public void setfRa(String fRa) {
        this.fRa = fRa;
    }

    public String gettAoi() {
        return tAoi;
    }

    public void settAoi(String tAoi) {
        this.tAoi = tAoi;
    }

    public String gettAg() {
        return tAg;
    }

    public void settAg(String tAg) {
        this.tAg = tAg;
    }

    public String gettRa() {
        return tRa;
    }

    public void settRa(String tRa) {
        this.tRa = tRa;
    }

    public String getClli() {
        return clli;
    }

    public void setClli(String clli) {
        this.clli = clli;
    }

    public String getTurf() {
        return turf;
    }

    public void setTurf(String turf) {
        this.turf = turf;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getfAoiRid() {
        return fAoiRid;
    }

    public void setfAoiRid(String fAoiRid) {
        this.fAoiRid = fAoiRid;
    }

    public String getfAgRid() {
        return fAgRid;
    }

    public void setfAgRid(String fAgRid) {
        this.fAgRid = fAgRid;
    }

    public String getfRaRid() {
        return fRaRid;
    }

    public void setfRaRid(String fRaRid) {
        this.fRaRid = fRaRid;
    }

    public String gettAoiRid() {
        return tAoiRid;
    }

    public void settAoiRid(String tAoiRid) {
        this.tAoiRid = tAoiRid;
    }

    public String gettAgRid() {
        return tAgRid;
    }

    public void settAgRid(String tAgRid) {
        this.tAgRid = tAgRid;
    }

    public String gettRaRid() {
        return tRaRid;
    }

    public void settRaRid(String tRaRid) {
        this.tRaRid = tRaRid;
    }

    public Date getReorgDt() {
        return reorgDt;
    }

    public void setReorgDt(Date reorgDt) {
        this.reorgDt = reorgDt;
    }

    @Override
    public String toString() {
        return "FmoReorgGeo [ID=" + ID + ", fAoi=" + fAoi + ", fAg=" + fAg + ", fRa=" + fRa + ", tAoi=" + tAoi
                + ", tAg=" + tAg + ", tRa=" + tRa + ", clli=" + clli + ", turf=" + turf + ", region=" + region
                + ", fAoiRid=" + fAoiRid + ", fAgRid=" + fAgRid + ", fRaRid=" + fRaRid + ", tAoiRid=" + tAoiRid
                + ", tAgRid=" + tAgRid + ", tRaRid=" + tRaRid + ", reorgDt=" + reorgDt + "]";
    }
    
    

}

FMOReorgGeoServiceImpl.java

import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import com.att.dmp.entity.FmoReorgGeo;
import com.att.dmp.repository.FMOReorgGeoRepository;
import com.att.dmp.service.FMOReorgGeoService;

@Service
@Qualifier("fMOReorgGeoServiceImpl")
public class FMOReorgGeoServiceImpl implements FMOReorgGeoService {

    private final Logger logger = LogManager.getLogger(FMOReorgGeoServiceImpl.class);

    @Autowired
    FMOReorgGeoRepository fMOReorgGeoRepository;

    @Override
    public List<FmoReorgGeo> updateResourceHierachyRID(String region, Date reorgDt) {
        List<Map<String, Object>> reorgRecords = Collections.emptyList();
        reorgRecords = fMOReorgGeoRepository.findreorgRecords(region, reorgDt);
        reorgRecords.forEach(map -> map.forEach((k, v) -> {
            logger.info(k + ":" + v);
        }));
        List<Map<String, Object>> updatedResourceHierachyRids = Collections.emptyList();
        for (Map<String, Object> reorgRecord : reorgRecords) {
            String f_aoi_rid = (String) reorgRecord.get("FAOIRID");
            String f_ag_rid = (String) reorgRecord.get("FAGRID");
            String f_ra_rid = (String) reorgRecord.get("FRARID");
            String t_aoi_rid = (String) reorgRecord.get("TAOIRID");
            String t_ag_rid = (String) reorgRecord.get("TAGRID");
            String t_ra_rid = (String) reorgRecord.get("TRARID");
            String clli = (String) reorgRecord.get("CLLI");
            String turf = (String) reorgRecord.get("TURF");
            updatedResourceHierachyRids = fMOReorgGeoRepository.updateRid(f_aoi_rid, f_ag_rid, f_ra_rid,t_aoi_rid, t_ag_rid,
                    t_ra_rid, clli, turf);

        }
        
        List<FmoReorgGeo> updatedFMOReorgGeos = new ArrayList<FmoReorgGeo>();

        if (!updatedResourceHierachyRids.isEmpty()) {
            
              for (Map<String, Object> updatedResourceHierachyRid :
              updatedResourceHierachyRids) { FmoReorgGeo rh = new FmoReorgGeo();
              rh.setfAoiRid((String) updatedResourceHierachyRid.get("F_AOI_RID"));
              rh.setfAgRid((String) updatedResourceHierachyRid.get("F_AG_RID"));
              rh.setfRaRid((String) updatedResourceHierachyRid.get("F_RA_RID"));
              rh.settAoiRid((String) updatedResourceHierachyRid.get("T_AOI_RID"));
              rh.settAgRid((String) updatedResourceHierachyRid.get("T_AG_RID"));
              rh.settRaRid((String) updatedResourceHierachyRid.get("T_RA_RID"));
              rh.setClli((String) updatedResourceHierachyRid.get("CLLI"));
              rh.setTurf((String) updatedResourceHierachyRid.get("TURF"));
              updatedFMOReorgGeos.add(rh); }
        }
        logger.info("Created updatedFMOReorgGeos are: {}", updatedFMOReorgGeos);
        return updatedFMOReorgGeos;
    }

}

FMOReorgGeoRepository.java

import java.sql.Date;
import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


import com.att.dmp.consts.AppConstant;
import com.att.dmp.entity.FmoReorgGeo;

@Repository
public interface FMOReorgGeoRepository extends JpaRepository<FmoReorgGeo, Integer> {
    
    @Query(value = AppConstant.SELECT_REORG_RECORDS_QUERY,nativeQuery = true)
    List<Map<String, Object>> findreorgRecords(@Param("region") String region,@Param("reorgDt") Date reorgDt);
    
    @Modifying
    @Query(value = AppConstant.UPDATE_RESOURCE_HIERACHY_RID,nativeQuery = true)
    List<Map<String, Object>> updateRid(@Param("F_AOI_RID") String f_aoi_rid,@Param("F_AG_RID") String f_ag_rid,@Param("F_RA_RID") String f_ra_rid,@Param("T_AOI_RID") String t_aoi_rid,@Param("T_AG_RID") String t_ag_rid,@Param("T_RA_RID") String t_ra_rid,@Param("CLLI") String clli,@Param("TURF") String turf);
}

ERROR LOG

Hibernate: update FMO_REORG_GEOS set F_AOI_RID = ?, F_AG_RID = ?, F_RA_RID = ?, T_AOI_RID= ?,T_AG_RID = ?,T_RA_RID = ? where CLLI = ? and TURF = ?
{"logType":"DEBUG","logLevel":"ERROR","logTimestamp":"2021-09-19T16:43:56.942-05:00","logger":"com.att.dmp.RestExceptionMapper","label":"Caught Exception in Jersey Service.....","runtime":{"instance":"unknown","clusterName":"unknown","namespace":"unknown","image":"unknown","platformIdentifier":"AJSC7_JERSEY"},"application":{"deploymentUnitName":"com.att.dmp.ReorgResourceCreatorMs","motsApplicationAcronym":"MOTS_ID"}}
{"logType":"EXCEPTION","logLevel":"ERROR","logTimestamp":"2021-09-19T16:43:56.945-05:00","logger":"Exception","label":"Exception","runtime":{"instance":"unknown","clusterName":"unknown","namespace":"unknown","image":"unknown","platformIdentifier":"AJSC7_JERSEY"},"application":{"deploymentUnitName":"com.att.dmp.ReorgResourceCreatorMs","motsApplicationAcronym":"MOTS_ID"},"exception":{"exceptionDetails":"Could not extract result set metadata; nested exception is org.hibernate.HibernateException: Could not extract result set metadata","stackTrace":"org.springframework.orm.jpa.JpaSystemException: Could not extract result set metadata; nested exception is org.hibernate.HibernateException: Could not extract result set metadatarntat org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:353)rntat org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)rntat org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:528)rntat org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)rntat org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)rntat org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)rntat com.sun.proxy.$Proxy246.updateRid(Unknown Source)rntat com.att.dmp.service.impl.FMOReorgGeoServiceImpl.updateResourceHierachyRID(FMOReorgGeoServiceImpl.java:45)rntat com.att.dmp.controller.RestControllerImpl.updateRID(RestControllerImpl.java:217)rntat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rntat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)rntat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rntat java.lang.reflect.Method.invoke(Method.java:498)rntat org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)rntat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)rntat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)rntat org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)rntat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)rntat org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)rntat org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)rntat org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)rntat org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253)rntat org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)rntat org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)rntat org.glassfish.jersey.internal.Errors.process(Errors.java:292)rntat org.glassfish.jersey.internal.Errors.process(Errors.java:274)rntat org.glassfish.jersey.internal.Errors.process(Errors.java:244)rntat org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)rntat org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232)rntat org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)rntat org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:392)rntat org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)rntat org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:365)rntat org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:318)rntat org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)rntat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)rntat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)rntat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)rntat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)rntat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)rntat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)rntat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)rntat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)rntat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)rntat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)rntat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)rntat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)rntat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)rntat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rntat java.lang.Thread.run(Thread.java:748)rnCaused by: org.hibernate.HibernateException: Could not extract result set metadatarntat org.hibernate.loader.custom.JdbcResultMetadata.<init>(JdbcResultMetadata.java:36)rntat org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:488)rntat org.hibernate.loader.Loader.processResultSet(Loader.java:2338)rntat org.hibernate.loader.Loader.getResultSet(Loader.java:2294)rntat org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2050)rntat org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)rntat org.hibernate.loader.Loader.doQuery(Loader.java:953)rntat org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)rntat org.hibernate.loader.Loader.doList(Loader.java:2815)rntat org.hibernate.loader.Loader.doList(Loader.java:2797)rntat org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2629)rntat org.hibernate.loader.Loader.list(Loader.java:2624)rntat org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)rntat org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2123)rntat org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1134)rntat org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173)rntat org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1526)rntat org.hibernate.query.Query.getResultList(Query.java:165)rntat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rntat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)rntat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rntat java.lang.reflect.Method.invoke(Method.java:498)rntat org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:409)rntat com.sun.proxy.$Proxy250.getResultList(Unknown Source)rntat org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:126)rntat org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88)rntat org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154)rntat org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142)rntat org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618)rntat org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)rntat org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)rntat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)rntat org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)rnt... 72 morernCaused by: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statementnrntat oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)rntat oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:388)rntat oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:381)rntat oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:564)rntat oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)rntat oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)rntat oracle.jdbc.driver.T4C8Odscrarr.doODNY(T4C8Odscrarr.java:98)rntat oracle.jdbc.driver.T4CPreparedStatement.doDescribe(T4CPreparedStatement.java:792)rntat oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:3928)rntat oracle.jdbc.driver.OracleResultSetMetaData.<init>(OracleResultSetMetaData.java:56)rntat oracle.jdbc.driver.OracleResultSetImpl.getMetaData(OracleResultSetImpl.java:170)rntat org.apache.commons.dbcp2.DelegatingResultSet.getMetaData(DelegatingResultSet.java:347)rntat org.apache.commons.dbcp2.DelegatingResultSet.getMetaData(DelegatingResultSet.java:347)rntat org.hibernate.loader.custom.JdbcResultMetadata.<init>(JdbcResultMetadata.java:33)rnt... 108 morern"}}

*I am trying to fetch data from reorgViewX and then updating FmoReorgGeo table. I am being able to fetch data correctly but when running update query I am getting error. The error says: Could not extract result set metadata; nested exception is org.hibernate.HibernateException: Could not extract result set metadata. I am using the concept of <Map<String, Object>> since hibernate does not allow fetching certain columns only and it needs to have all columns while fetching. *

Advertisement

Answer

An update query like this doesn’t return a result set. Remove the return type:

@Modifying
@Query(value = AppConstant.UPDATE_RESOURCE_HIERACHY_RID,nativeQuery = true)
void updateRid(@Param("F_AOI_RID") String f_aoi_rid,@Param("F_AG_RID") String f_ag_rid,@Param("F_RA_RID") String f_ra_rid,@Param("T_AOI_RID") String t_aoi_rid,@Param("T_AG_RID") String t_ag_rid,@Param("T_RA_RID") String t_ra_rid,@Param("CLLI") String clli,@Param("TURF") String turf);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement