Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to refresh updated entity data without restarting the server
    primarykey
    data
    text
    <p>I am using EclipseLink JPA as ORM and web logic 10.3 as an application server in my project. Everything working fine until i got a bug for data refresh. Here is the case one of my entity table row is updated to new value but my entity manager or JPA did not pick that value. For this we have lite rely re started the server. then it picked up the value.</p> <p>Here is my persistence.xml file and here is the way i am using entity manager in my class.</p> <pre><code>&lt;persistence-unit name="BasePersistenceUnit" transaction-type="JTA"&gt; &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt; &lt;jta-data-source&gt;jdbc/CTH_DS&lt;/jta-data-source&gt; &lt;class&gt;org.test.partyrequest.model.dataobject.RqstTrc&lt;/class&gt; &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt; &lt;properties&gt; &lt;property name="eclipselink.target-server" value="WebLogic_10" /&gt; &lt;!-- Logging level is set to INFO, Need to change in Production --&gt; &lt;property name="eclipselink.logging.level" value="FINE" /&gt; &lt;property name="eclipselink.persistence-context.flush-mode" value="COMMIT" /&gt; &lt;property name="eclipselink.persistence-context.close-on-commit" value="true" /&gt; &lt;property name="eclipselink.cache.shared.default" value="false" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>SPRING JPA XML FILE</p> <pre><code>&lt;context:load-time-weaver aspectj-weaving="on" /&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceUnitName" value="BasePersistenceUnit" /&gt; &lt;/bean&gt; &lt;bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter" /&gt; &lt;bean id="transactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager" /&gt; &lt;!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --&gt; &lt;!-- Instruct Spring to perform declarative transaction management automatically on annotated classes. --&gt; &lt;tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/&gt; &lt;!-- Post-processor to perform exception translation on @Repository classes (from native exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy). --&gt; &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt; </code></pre> <p>My Entity calss</p> <pre><code>@Entity </code></pre> <p>@Table(name = "PRTY_RQST") public class PrtyRqst implements Serializable {</p> <pre><code>private static final long serialVersionUID = -4679712398918736694L; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PRTY_RQST_PRTYRQSTID_GENERATOR") @SequenceGenerator(name = "PRTY_RQST_PRTYRQSTID_GENERATOR", allocationSize = 1, sequenceName = "PRTY_RQST_SEQ") @Column(name = "PRTY_RQST_ID") private Long prtyRqstId; @Column(name = "CHLD_RQST_IND") private String chldRqstInd; @Column(name = "PARNT_PRTY_RQST_ID") private BigDecimal parntPrtyRqstId; @Column(name = "PROCES_REFR") private String procesRefr; @Temporal(TemporalType.TIMESTAMP) @Column(name = "RQST_DT_TM") private Date rqstDtTm; @Column(name = "UPDT_BY") private String updtBy; // bi-directional many-to-one association to PrtyKey @OneToMany(mappedBy = "prtyRqst", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List&lt;PrtyKey&gt; prtyKeys; // bi-directional many-to-one association to PrtyRqstHist @OneToMany(mappedBy = "prtyRqst", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @OrderBy("rqstDtTm DESC") private List&lt;PrtyRqstHist&gt; prtyRqstHists; @OneToOne(mappedBy = "prtyRqst", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private RqstPayload rqstPayload; // bi-directional many-to-one association to RqstTrc @OneToMany(mappedBy = "prtyRqst", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List&lt;RqstTrc&gt; rqstTrcs; // bi-directional many-to-one association to AddtnRqstInfo @OneToMany(mappedBy = "prtyRqst", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List&lt;AddtnRqstInfo&gt; addtnRqstInfos; // bi-directional many-to-one association to BusnApplc @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) @JoinColumn(name = "BUSN_APPLC_ID") private BusnApplc busnApplc; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) @JoinColumn(name = "INTN_PROCES_TYP_ID") private IntnProcesTyp intnProcesTyp; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) @JoinColumn(name = "INTN_STATS_ID") private IntnStat intnStat; @Column(name = "ORCHESTRATION_ID") private String orchestrationId; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) @JoinColumn(name = "ALLW_CHNL_ID") private AllwChnl allwChnl; // bi-directional many-to-one association to RqstTyp @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) @JoinColumn(name = "RQST_TYP_ID") private RqstTyp rqstTyp; @Column(name = "TRACK_RQST_IND") private String trackRqstInd; @Temporal(TemporalType.TIMESTAMP) @Column(name = "SUBMIT_DT_TM") private Date submitDtTm; @Temporal(TemporalType.DATE) @Column(name = "EFFECTIVE_DT") private Date effectiveDt; @Temporal(TemporalType.TIMESTAMP) @Column(name = "RQST_CREATE_DT_TM") private Date rqstCreateDtTm; </code></pre> <p>In my DAO IMPL class I have this.persist(prtyRqstDO);</p> <pre><code>@Transactional(readOnly = true, propagation=Propagation.REQUIRED) private PartyRequestBO createRequest(PartyRequestBO partyRequestBO, boolean isParent) throws RuntimeException { if (log.isDebugEnabled()) { log.debug("Enter: PartyRequestsDAOImpl:createRequest()"); } partyRequestBO.setOrchestrationID(generateOrchestrationId()); PrtyRqst prtyRqstDO = PartyRequestEntityMapper.partyRequestMapper(partyRequestBO, isParent, true); try { this.persist(prtyRqstDO); partyRequestBO.setRequestIdentifier(prtyRqstDO.getPrtyRqstId()); } catch (Exception e) { if(log.isDebugEnabled()) { log.debug("PartyRequestsDAOImpl:createRequest : " + PartyRequestConstants.UNABLE_TO_INSERT, e); } throw new PartyRequestDataException(PartyRequestConstants.UNABLE_TO_INSERT, e); } if (log.isDebugEnabled()) { log.debug("Exit: PartyRequestsDAOImpl:createRequest()"); } return partyRequestBO; } @Transactional(readOnly = true, propagation=Propagation.REQUIRED) public void persist(T entity) { if (log.isDebugEnabled()) { log.debug("Enter: BaseDAO:persist() : " + entity); } this.getEntityManager().persist(entity); if (log.isDebugEnabled()) { log.debug("Exit: BaseDAO:persist()"); } } public EntityManager getEntityManager() { if (log.isDebugEnabled()) { log.debug("Enter: BaseDAO:getEntityManager() : " + this.entityManager); } return this.entityManager; } </code></pre> <p>Here the problem is, if i update the row in one of the table through back end my application container is not picking the change.</p> <p>Can any one Tell me? thank you in advance.</p> <p>EDIT:</p> <p>Thank you both of you. I have modified according to your comments added following lines of code.</p> <pre><code>this.entityManager.clear(); this.entityManager.close(); //this.getEntityManager().refresh(entityManager); </code></pre> <p>Here i could able to get the update value what i have done it through backend with out restarting server. But the problem is it hold all the changed values.</p> <p>for example i have changed value to <strong>FulOrderWSA</strong> it was working. changed to <strong>FulorderWSB</strong> it was working again.Now i have tried for <strong>FulOrderWSZ</strong> it didn't work(DB values is FulorderWSB ). </p> <p>Finally i tried here with old value that is <strong>FulorderWSA</strong> as per DB it should not work but it worked for me. what i noticed that it is holding all the DB changed values here.</p> <p>How to get ride of this. I have used both clear and close for entityManager. can any one help me on this. </p> <p>thank you. </p> <p>Vijay.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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