VisualBuilder
  Home > Ejb > Tutorials > Create Entity Bean: - EJB 3 Tutorial
Tell a friend
Link to us
Total Members
      Members: 84606
     
Sitemap Forum Chat
Home
EJB 3 Tutorial Home
1 . Introduction to EJB 3 with movies
2 . Set Up the EJB 3 environment with Movies
3 . Creating the J2EE Project
4 . Inspecting the J2EE Project
5 . Create Session Bean skeleton:
6 . Create Entity Bean:
7 . Create the Session Bean POJI
8 . Define the POJI methods
9 . The EntityManager:
10 . Coding the business methods:
11 . Configure Persistence Unit
12 . Struts - a quick overview:
13 . Create the Struts Web layer:
14 . The Struts configuration file:
15 . The execute method:
16 . The insert & delete methods
17 . Javascript functions
18 . JSP body
19 . Deploy, review database and Test:
20 . Example Code
21 . Example Code
 
Ejb Group Home
Ejb Discussion (3)
Ejb Members (2720)
Ejb Resources
Ejb Source Code (0)
Ejb Articles (0)
Ejb Blogs
Ejb Jobs
Ejb Components (0)
Ejb Books
Ejb Websites (5)
Ejb News (4)
Ejb Q & A (6)
- Ejb Ask Question
- Ejb Questions
- Ejb Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (432 )
Source Code (3217 )
Articles (11 )
Components (1589 )
News (880 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Ejb Tutorial
 Create Entity Bean:
  << Prev: Create Session Bean skeleton: Next: Create the Session Bean POJI >>

The server automatically generates the Integer primary key for the id property because it is annotated with @GeneratedValue (strategy = Generation.Type.AUTO).


In addition to the generated source we need to add a constructor that will take the author and title Strings.


The Book.java is an ordinary POJO declared as an Entity Bean to the server by the annotations @Entity and the primary key field @Id (and @GeneratedValue). The strategy for GeneratedValue defines how the persistence provider must generate the annotated primary key.


In this case we can see that our primary key is an Integer called id and the strategy is the default GenerationType.AUTO. As suggested, this means that the persistence provider will create a new id for all new entities added to the database.




As you can see, the Book class has three properties, java.lang.Integer id our primary key, java.lang.String title and java.lang.String author. These will map to the fields in the table that will be created for us by the persistence provider.


We've added getters and setters and an additional constructor that takes title and author parameters so we can create an entity from new keyword.


See what I did here



  << Prev: Create Session Bean skeleton: Next: Create the Session Bean POJI >>
Ejb Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
MSN
Video Surveillance
VoIP Internettelefonie DE
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising