I have the following problem:
I need to instantiate a POJO from my DAO whose the class is passed as a parameter.
both
Code:
newNode = clazz.newInstance();
newNode.setCreationDate(new Timestamp(new Date().getTime()));
and
Code:
newNode = clazz.getConstructor().newInstance();
newNode.setCreationDate(new Timestamp(new Date().getTime()));
with clazz = Node.class
give a NPE:
java.lang.NullPointerException
at org.taktik.nadi.Node$$EnhancerByCGLIB$$93c8c57f.setCreationDate(<generated>)
at org.taktik.nadi.dao.impl.NodeDAOImpl.create(NodeDAOImpl.java:62)
while
Code:
newNode = new Node();
newNode.setCreationDate(new Timestamp(new Date().getTime()));
works like a charm.
Is this an expected behaviour. If yes, is there any way (using Metaclass.instantiate for example) to instantiate a POJO from its class.
Thanks in advance,
Antoine