|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Object Version in Eclipse LinkAim:- To provide object versioning. Each table in the schema contain a column called ObjectVersion
What is an equivalent of http://www.jboss.org/envers/ in eclipse link? |
|
|
Re: Object Version in Eclipse LinkEclipseLink has similar functionality that is not yet exposed through
annotations or JPA. Here are some links to the TopLink user guides. Although this user guide is for TopLink the same functionality and Classes exist in EclipseLink just under different names. http://download.oracle.com/docs/cd/B32110_01/web.1013/b28218/hisus.htm for queries. http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/descfg030.htm to have EclipseLink maintain revisions. To get access to a ServerSession from JPA for acquiring a HistoricSession you can perform the following: JPAHelper.getEntityManager(em).getServerSession(); or JPAHelper.getEntityManagerFactory(emf).getServerSession(); --Gordon Gaurav Malhotra wrote: > Aim:- To provide object versioning. Each table in the schema contain a column > called ObjectVersion > > What is an equivalent of http://www.jboss.org/envers/ in eclipse link? > _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: Object Version in Eclipse LinkI have another question
Say for example there is table code with following column Code StartDate EndDate (dd/mm/yyyy) 1 1/1/2008 5/1/2008 2 3/1/2008 9/1/2008 3 4/5/2008 7/5/2008 Business RUle 1. Insert the code based on non-overlapping time intervals 2.There will bulk inserts (say in the order of few millons) As a result code 1,3 are fine, code 3 should generate the error message :- Not valid time interval Suggest some optimized way to perform this. Eagerly awaiting reply
|
|
|
Re: Object Version in Eclipse LinkI found the way to solve this issue, here is code snippet (I used named query) , may be it helpful to somebody
1. All entity extends Persitable interface (act as marker interface) 2. Enitity which require time validity check implement interface PersistableWithTimeValidity DAO looks like public interface GenericDAO<T extends Persistable> { public void create(T t); public T update(T t); @SuppressWarnings("unchecked") public T get(Class clas, Serializable id); @SuppressWarnings("unchecked") public void delete(Class clas, Serializable id); public void delete(T t); public List<T> findByExample(T exampleCriteria); @SuppressWarnings("hiding") public <T> List<T> selectAll(Class<T> clazz,String orderClause); @SuppressWarnings("hiding") public <T> T findFresh(Class<T> entityClass, Object primaryKey); public <T> List<T> getNamedQuery(final Class<T> entityClass, final String namedQuery, final Object... binds); public <T> List<T> getNamedQuery(final Class<T> entityClass, final String namedQuery, final Map<String,Object> binds); } Service looks like public interface CrudService<T extends Persistable> { /** * Retrieve the object from db given its ID. * * @param id * the id * * @return the Persistable object */ @SuppressWarnings("unchecked") public T retrieve(Class klass, Serializable id); /** * Creates a new Persistable in the system. * * @param persistable * * @return the persisted persistable (possibly with an ID) */ public T create(T persistable); /** * Updates the persistable to db. * * @param persistable */ public T update(T persistable); @SuppressWarnings("unchecked") public void remove(Class klass, Serializable id); public List<T> findByExample(T exampleCriteria); @SuppressWarnings("hiding") public <T> List<T> selectAll(Class<T> clazz, String orderClause); @SuppressWarnings("hiding") public <T> T findFresh(Class<T> entityClass, Object primaryKey); @SuppressWarnings("hiding") public <T> List<T> getNamedQuery(final Class<T> entityClass, final String namedQuery, final Map<String,Object> binds); public boolean isTimeValid(T persistable); } Time validity check :- // Oh yes, perform the check for time validity PersistableWithTimeValidity persistTv = null; String msg = "This entity cannot be checked for time validity"; Assert.isInstanceOf(PersistableWithTimeValidity.class, persistable, msg); // if (persistable instanceof PersistableWithTimeValidity) { persistTv = (PersistableWithTimeValidity) persistable; Timestamp startDate = persistTv.getStartDate(); Timestamp endDate = persistTv.getEndDate(); Map<String, Object> keyMap = persistTv.getKeyForTimeValidity(); Set<String> keySet = keyMap.keySet(); Map<String,Object> mp = new LinkedHashMap<String, Object>(); for (String key : keySet) { mp.put(key, keyMap.get(key)); } mp.put("startDate", startDate); mp.put("endDate", endDate); Class klass = persistTv.getClass(); String nQry = persistTv.getClass().getSimpleName()+ NAMED_QUERY_TIMEVALIDITY; List<PersistableWithTimeValidity> list = null; list = (List<PersistableWithTimeValidity>) genericDao.getNamedQuery(klass,nQry, mp); Eclipse link rocks :-) (complement to team. I have been using Hibernate and Hibernate + AndroMDA for long. Eclipse link is quicker to learn and vast features)
|
| Free embeddable forum powered by Nabble | Forum Help |