Hi Matej,

Thank you for your reply but I managed to resolved the issue of getting the id. It is something fundamental and yet I had no idea where I had gone wrong till I read a Dzone article about null pointer exception.

I thought using Dependency injection will solve my problem, after trying things out for so long.

However, I would still be interested to find out how WELD CDI is different from EJB’s ( I beg your pardon if there isn’t cos I hadn’t the chance touch on EJB since I left my studies). 

I read from Adam Biden’s using Weld CDI with Tomcat so I do not know if cost savings is the reason. 

Hope to hear from you again.

Many thanks.

Karen




Sent from Yahoo Mail for iPhone

On Wednesday, January 2, 2019, 4:35 PM, Matej Novotny <manovotn@redhat.com> wrote:

Hello Karen,

Is your code public on GitHub (or somewhere else)?
It would be easier to try and help you if I could see the code.
From just the description I don't really understand how do you leverage CDI in your design and which bits work and which don't.

Regards
Matej

----- Original Message -----
> From: "Karen Goh" <karenworld@yahoo.com>
> To: weld-dev@lists.jboss.org
> Sent: Monday, December 24, 2018 11:26:38 AM
> Subject: [weld-dev] Clarification needed for using WELD CDI
>
> Hi,
>
> I am a beginner in WELD CDI and my purpose of this email is to clarify if
> WELD CDI can be used in this scenario.
>
> Basically, I started out my web app project using Java, JEE and jsp and DAO
> design.
>
> The thing is I have problem in getting the id of an entity.
>
> So, my question is how do I use Weld to get the Id and then used it in my
> DAOimpl ?
>
> I have a insert(Tutor t) method in tutorDAOImpl.
>
> Once the tutor's data is inserted into MYSQL the id is in as well cos it is
> using Autoincrement.
>
> So, I'm thinking of how to use Weld to get the tutor Id since I have the
> getter in tutor_id in Tutor class.
>
> In this DAO design, there is also a Manager or Service class which call the
> tutorDAOImpl's method and it is in turn called by the Controller.
>
> If Weld CDI can be used in my case, please tell me how to go about
> implementing it.
>
> Thank you & regards,
> Karen


>
> _______________________________________________
> weld-dev mailing list
> weld-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev

>