-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NPE while instantiating a pojo using aClass.newInstance()
PostPosted: Wed Aug 29, 2007 3:23 pm 
Newbie

Joined: Wed Aug 29, 2007 3:12 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.