01: package com.completex.objective.components.persistency.mapper.impl;
02:
03: import com.completex.objective.components.persistency.PersistentObject;
04: import com.completex.objective.components.persistency.mapper.Mapper;
05: import com.completex.objective.components.persistency.mapper.ThreadSession;
06:
07: /**
08: * @author Gennady Krizhevsky
09: */
10: public class DynamicBeanToPoMapperImpl extends BasicDynamicMapperImpl {
11:
12: public DynamicBeanToPoMapperImpl(Mapper mapper) {
13: super (mapper);
14: }
15:
16: protected Object objectNewInstance(Class beanClass,
17: Object fromObject, boolean forModification) {
18: PersistentObject po = (PersistentObject) ThreadSession.getPo(
19: getMapper(), fromObject);
20:
21: if (po != null) {
22: if (po.flattened()) {
23: po.unflatten();
24: }
25: } else {
26: po = (PersistentObject) super.objectNewInstance(beanClass);
27: }
28:
29: if (forModification) {
30: ThreadSession.set(getMapper(), fromObject, po);
31: }
32:
33: return po;
34: }
35:
36: }
|