• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java Persistence API

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi,

I am developing a web app against glassfish v2ur2 and MySQL 5.0. I am going to use session and entities EJB3 class. And I am having problems to understand the Java Persistence API. I mean:

#1.- Do I need an Entity for any table in the DB?
#2.- On first time I am going to do only select queries, but exists a
relationship type of many-to-many between tables in the DB I solved
with normalization. How do I indicate this relationship in the code?
#3.- I do not use keyGen to generate the PKs. All of them are type of auto-increment.
Is this problematic?
#4.-Do I need an Entity for everyone relation table?

To have you an idea of what I am going to do, it is something like the Duke’s Bank.

Thanks in advance,
Jose Alvarez de Lara

 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

A fellow explin me the questions, so it let me develop a simple example.
It has two entities, a stateless session as facade and the app client.

Every entity map a table.

Here is the code,












And I get a NullPointerException. Here is the stacktrace,



Any idea?

Best regards,
Jose Alvarez de Lara
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me that the DI did not work and the sb reference is null. Could you tell us how you are deploying your application?
 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your interesting.

I solved the issue injecting the EJB in a servlet and it worked fine.
So I wanted to go further and develop a web application with three tiers:

#1.- the entities Customer and Order,

#2.- the stateful session ejb CustomerControllerBean and OrderControllerBean that use two JavaBean named CustomerDetails and OrderDetails that represent a Customer and an Order,

#3.- and finally the web tier with some JSPs , a controller Servlet, and two JavaBeans named CustomerBean and OrderBean where I inject the ejb remote interfaces

The idea is to use use the CustomerBean and OrderBean as façade.
Well, as I told you above the firs web application run ok injecting the ejb remote interfaces in the servlet.
But the second and more complicated web application do not works. The problem is the same that you observed in my initial posted application: the injected ejb fails and throw a NullPointerException.

I use Eclipse Ganymede RS1 To develop and deploy the web app on glassfish v2ur2.

Regards,
Jose Alvarez de Lara
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic