Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to refresh the entities with out re starting the server(How to refresh the entities with out re starting the server)
How to refresh the entities with out re starting the server [message #1053061] Thu, 02 May 2013 05:37 Go to next message
Eclipse UserFriend
Hi All,

I am new to Eclipse Link. I have project that consumes Eclipse link in web logic server. My problem is when ever i update any row value using backed it is not getting reflected for that i have to restart my server.

Here is my persistence.xml file

<persistence-unit name="BasePersistenceUnit" transaction-type="JTA">
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
		<jta-data-source>jdbc/CTH_DS</jta-data-source> 
		<class>org.test.partyrequest.model.dataobject.RqstTrc</class>
		<exclude-unlisted-classes>true</exclude-unlisted-classes>

		<properties>
			<property name="eclipselink.target-server" value="WebLogic_10" />
			<!-- Logging level is set to INFO, Need to change in Production -->
			<property name="eclipselink.logging.level" value="FINE" />
			<property name="eclipselink.persistence-context.flush-mode" value="COMMIT" />
			<property name="eclipselink.persistence-context.close-on-commit" value="true" />
			<property name="eclipselink.cache.shared.default" value="false" /> 		
		</properties>
	</persistence-unit>


My Entity class

@Entity
@Table(name = "BUSN_APPLC")
@NamedQueries({
	@NamedQuery(name = "fetchBusinessApplications",      query = "SELECT busnApps FROM BusnApplc busnApps "),
    @NamedQuery(name = "fetchBusinessApplicationByName", query = "SELECT busnApps FROM BusnApplc busnApps "
    														   + "WHERE busnApps.busnApplcNm = :busnApplc ")
})
public class BusnApplc implements Serializable {
	
	private static final long serialVersionUID = -2034912319094137940L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BUSN_APPLC_BUSNAPPLCID_GENERATOR")
	@SequenceGenerator(name = "BUSN_APPLC_BUSNAPPLCID_GENERATOR", allocationSize = 1, sequenceName = "BUSN_APPLC_SEQ")
	@Column(name = "BUSN_APPLC_ID")
	private Long busnApplcId;
	
	@Column(name = "BUSN_APPLC_DSCR")
	private String busnApplcDscr;
	
	@Column(name = "BUSN_APPLC_NM")
	private String busnApplcNm;
	
	// bi-directional many-to-one association to PrtyRqst
	@OneToMany(mappedBy = "busnApplc", fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	private List<PrtyRqst> prtyRqsts;
	
	// bi-directional many-to-one association to PrtyRqstHist
	@OneToMany(mappedBy = "busnApplc", fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	private List<PrtyRqstHist> prtyRqstHists;
	
	public Long getBusnApplcId() {
		return this.busnApplcId;
	}

Here is my DAO IMPL class where i am using entity manager
@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()");
		}
	}


can any tell how can i get the updated value with out restarting the server.

Thank you in advance.
Vijay
Re: How to refresh the entities with out re starting the server [message #1053275 is a reply to message #1053061] Fri, 03 May 2013 09:47 Go to previous message
Eclipse UserFriend
This was asked here with some suggestions provided:
http://stackoverflow.com/questions/16331621/how-to-refresh-updated-entity-data-without-restarting-the-server

what is needed though is information on how you are reading the entity and seeing stale data. If you are getting a new EM and have disabled the shared cache, it should simply be a matter of re reading the entity, giving you a managed instance that reflects the data from the database. You might also want to share what is stale and how it was changed, as there maybe a better option than turning the shared cache off to get that data.

[Updated on: Fri, 03 May 2013 09:48] by Moderator

Previous Topic:Complex Key: Multiple writable mappings exist;
Next Topic:Loading an XML file with SDO
Goto Forum:
  


Current Time: Mon Jul 14 10:17:06 EDT 2025

Powered by FUDForum. Page generated in 0.03923 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top