|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
SCJP mock test | SCJP DUMP | SCWCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc) JobsJobs and Walkins

Tutorial Home
SCJP 6 Simulator Exam Kit
OCAJP 7 Simulator Exam Kit
OCPJP 7 Simulator Exam Kit
SCWCD5.0 Simulator Exam Kit
OCEJWCD 6 Simulator Exam Kit
Struts Tutorial Home
Spring Tutorial Home
Hibernate Tutorial Home
JSP Tutorial Home
JDBC Tutorial Home
Webservices Tutorial Home
EJB Fundamentals

Hibernate

  1. Advantage of Hibernate over JDBC

  2. Hibernate Setup with an web Application

  3. First Hibernate Application

  4. Hibernate mapping with Database TABLE

  5. Hibernate Data Type-Java Data Type - SQL Data Type mapping

  6. One to Many Relation in Hibernate

  7. One to Many Relation in Hibernate bi-directional

  8. Many to Many Relation in Hibernate

  9. HQL: The Hibernate Query Language

  10. Criteria Queries

  11. Criteria Queries : Equal (eq), Not Equal(ne), Less than (le), greater than (gt),greater than or equal(ge) and Ordering the results

  12. Criteria Queries: And OR conditions

  13. Hibernate generator to generate id (primary key)

  14. prevent concurrent update in Hibernate,slate object updatation in Hibernate,version checking in Hibernate

    Struts


  1. Model View Controller (MVC)

  2. Model View Controller (MVC)

  3. Struts Flow-How Struts Works?

  4. Struts Tutorial - Struts Setup- First Struts Action class setup

  5. Message Resources

  6. Validation Framework

  7. Validation Framework-client side

  8. ForwardAction

  9. IncludeAction

  10. DispatchAction

  11. LookupDispatchAction

  12. DynaActionForm

  13. DynaActionForm

  14. Struts Tutorial - Mutli-click prevention using struts tokens-Prevent Duplicate Submission

  15. Logic Iterate Map and List


JSP


  1. JSP Tutorial

  2. Introduction to JSP

  3. JSP Comments

  4. JSP Syntax

  5. JSP Scripting Elements :Scriptlet, expression, declaration

  6. JSP Directives

  7. implicit objects in JSP

  8. JSP Actions

  9. Introduction to JSP

  10. jsp:useBean

  11. The jsp:setProperty Action

  12. The jsp:getProperty Action

  13. Introduction to JSP



Spring



  1. Spring Tutorial

  2. Introduction to Spring

  3. Benefits of Using Spring Framework

  4. Inversion of Control in Spring

  5. Introduction to BeanFactory

  6. Dependency Injection in Spring

  7. Collections Setter Injection

  8. Bean Scopes in Spring

  9. Spring IOC Setup Step by Step

  10. Bean Lifecycle in Spring

  11. ApplicationContext

  12. MessageSources in Spring

  13. Web Spring MVC framework

  14. Developing Your First Spring Web Application

  15. Developing Your Second Spring Web Application with Spring Form

  16. Developing Your First Spring Web Application with Spring Validation Framework with Code Example

  17. Spring integration with Hibernate

Identify correct and incorrect statements or examples about an entity bean's primary key and object identity.

From the viewpoint of the Bean Provider, entity objects have a runtime object identity that is maintained by the Container.

The Container maintains the persistent identity of an entity object on the basis of its PRIMARY KEY.

The primary key of an entity bean may or may not be visible as one or more cmp-fields of the instance, depending on the way in which it is specified. Once it has been set, the Bean Provider MUST NOT attempt to change the value of a primary key field by means of a set method on its cmp-fields.

When a new instance of an entity bean whose primary key fields are visible in the entity bean class is created, the Bean Provider MUST use the ejbCreate<METHOD>(...) method to set all the primary key fields of the entity bean instance before the instance can participate in a relationship, e.g. be used in a set accessor method for a cmr-field. The Bean Provider MUST NOT reset a primary key value by means of a set method on any of its cmp-fields after it has been set in the ejbCreate<METHOD>(...) method.

The container must be able to manipulate the primary key type of an entity bean. Therefore, the primary key type for an entity bean with container-managed persistence MUST follow the rules:

  • The Bean Provider MUST specify a primary key class in the deployment descriptor. (In case the class is not known until deployment, Bean Provider specify java.lang.Object class).

  • The primary key type MUST be a legal Value Type in RMI-IIOP (serializable).

  • The class MUST provide suitable implementation of the hashCode() and equals(Object obj) methods to simplify the management of the primary keys by the Container.

There are two ways to specify a primary key class for an entity bean with container-managed persistence:

  1. Primary key that maps to a SINGLE field in the entity bean class.

    The Bean Provider uses the primkey-field element of the deployment descriptor to specify the container-managed field of the entity bean class that contains the primary key. The field’s type must be the primary key type.

    								
    <entity>
    	<ejb-name>CabinEJB</ejb-name>
    	<home>com.titan.cabin.CabinHomeRemote</home>
    	<remote>com.titan.cabin.CabinRemote</remote>
    	<ejb-class>com.titan.cabin.CabinBean</ejb-class>
    	<persistence-type>Container</persistence-type>
    	<prim-key-class>java.lang.Integer</prim-key-class>
    	<reentrant>False</reentrant>
    	<cmp-version>2.x</cmp-version>
    	<abstract-schema-name>Cabin</abstract-schema-name>
    	<cmp-field><field-name>id</field-name></cmp-field>
    	<cmp-field><field-name>name</field-name></cmp-field>
    	<cmp-field><field-name>deckLevel</field-name></cmp-field>
    	<cmp-field><field-name>shipId</field-name></cmp-field>
    	<cmp-field><field-name>bedCount</field-name></cmp-field>
    	<primkey-field>id</primkey-field>
    	<security-identity><use-caller-identity/></security-identity>
    </entity>
    								
    								

  2. Primary key that maps to MULTIPLE fields in the entity bean class.

    The primary key class MUST be public, and MUST have a public constructor with NO PARAMETERS.

    ALL fields in the primary key class MUST be declared as public.

    The names of the fields in the primary key class MUST be a subset of the names of the container-managed fields.

public class ItemKey implements java.io.Serializable {
	public String productId; // public - mandatory
	public String vendorId; // public - mandatory
	public ItemKey() { }; // no-args constructor - mandatory
	
	public ItemKey(String productId, String vendorId) {
		this.productId = productId;
		this.vendorId = vendorId;
	}
	
	public String getProductId() {
		return productId;
	}

	public String getVendorId() {
		return vendorId;
	}
	
	public boolean equals(Object other) { // mandatory
		if (other instanceof ItemKey) {
			return (productId.equals(((ItemKey)other).productId) 
			&& vendorId.equals(((ItemKey)other).vendorId));
		}
		return false;
	}

	public int hashCode() { // mandatory
		return productId.hashCode();
	}
}
					
A primary key class MUST meet these requirements:
  • The access control modifier of the class is public.

  • All fields are declared as public.

  • Field names in the primary key clsss MUST match the corresponding container-managed fields in the entity bean class.

  • The class has a public default (no-args) constructor.

  • The class implements the hashCode() and equals(Object obj) methods.

  • The class is SERIALIZABLE (implements java.io.Serializable).

In special situations, the entity Bean Provider may choose not to specify the primary key class or the primary key fields for an entity bean with container-managed persistence. This case usually happens when the entity bean does not have a natural primary key, and/or the Bean Provider wants to allow the Deployer using the Container Provider’s tools to select the primary key fields at deployment time. The entity bean’s primary key type will usually be derived from the primary key type used by the underlying database system that stores the entity objects. The primary key used by the database system may not be known to the Bean Provider.

In this special case, entity bean must meet these requirements:

  • In the deployment descriptor, the primary key class is defined (by Bean Provider) as a java.lang.Object. The primary key field is not specified.

  • In the HOME interface, the argument of the findByPrimaryKey method MUST be a java.lang.Object.

  • In the entity bean CLASS, the return type of the ejbCreate method MUST be a java.lang.Object.

We are using 2 elements in DD for defining primary keys: <prim-key-class> and <primkey-field> :

  • SINGLE-FIELD primary key: <prim-key-class> is a MANDATORY, <primkey-field> is a MANDATORY.

  • COMPOUND primary key: <prim-key-class> is a MANDATORY, <primkey-field> MUST NOT be defined.

The primary key class can be specific to a particular entity bean class. That is, each entity bean can define its own primary key class. Or multiple entity beans CAN share the same primary key class.

If two entity objects with the SAME home interface have the SAME primary key, they are considered IDENTICAL entity objects. If they have a different primary key, they are considered different entity objects.

There are 2 ways of comparing Entity Beans:

  1. Using isIdentical(EJBObject obj) method of javax.ejb.EJBObject interface on bean's REMOTE interface, or isIdentical(EJBLocalObject obj) method of javax.ejb.EJBLocalObject interface on bean's LOCAL interface.

    Item item1 = ...;
    Item item2 = ...;
    
    if (item1.isIdentical(item2)) {
    	// item1 and item2 refer to the same entity object
    }
    							

  2. Comparing primary keys of two entity object references (ONLY FROM THE SAME HOME INTERFACE !).

    ItemHome itemHome = ...; // get home interface
    Item item1 = itemHome.findByName(...);
    Item item2 = itemHome.findByCountry(...);
    
    if (item1.getPrimaryKey().equals(item2.getPrimaryKey())) {
    	// item1 and item2 refer to the same entity object
    }
    							

SCJP 6 Simulator Exam Kit
OCAJP 7 Simulator Exam Kit
OCPJP 7 Simulator Exam Kit
SCWCD5.0 Simulator Exam Kit
OCEJWCD 6 Simulator Exam Kit

Suggested Jobs

   More Jobs >>
The information you are posting should be related to java and ORACLE technology. Not political. SCJP 5.0 Simulator 642+ Questions With Explanations
SCJP 6.0 Simulator 664+ Questions With Explanations
SCWCD 5.0 Simulator 556+ Questions With Explanations
SCWCD 4.0 Simulator 500+ Questions With Explanations
OCA 10g Simulator 594+ Questions With Explanations
Hiring made easy Harness social networking, employee referrals, Agency portal and Job Portals