Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

BMP with PrimaryKey class problem.  RSS feed

 
Roy Huang
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I 'm writing a Bean managed persistence Entity Bean.
In the ejbFindFindByPrimaryKey()method, I have to give a primary key class object-- since in my DB table, 2 kinds of the data elements can together define a record of the DB. so I need create a primary key class for it.
But ther're few examples about this kind of part in some tutorials. Can anyone offer some similar code example from Ur experience or from other tutorials?
Thanks,
Roy
 
krishna chitturi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
here is pk class of having two attributes as primary key.

import java.io.Serializable;
import java.sql.Timestamp;
/**
* Entity PrimaryKey for Report
*
* @author
*/
public class ReportEntityPK implements Serializable {
/**
* Attributes declaration
*/
private long id;
private Timestamp lastUpdated;
/**
* @roseuid 3D97D2A703C7
* @J2EE_METHOD -- hashCode
* Referencing to object that represetns the entity object.
*/
public int hashCode () {
return 0;
}
/**
* @roseuid 3D97D2A703CF
* @J2EE_METHOD -- equals
* Method that compares two entity object references -- since the Java Object.equals(Object
* obj) method is unspecified.
*/
public boolean equals (java.lang.Object obj) {
return true;
}
/**
* @roseuid 3D97D2A703D1
* @J2EE_METHOD -- toString
* Own toString() method of a bean's PK class.
*/
public java.lang.String toString () {
return null;
}
/**
* @roseuid 3D97F3AB00F7
* @J2EE_METHOD -- ReportEntityPK
*/
public ReportEntityPK () {
}
/**
* @roseuid 3DCB5BE20253
* @J2EE_METHOD -- ReportEntityPK
*/
public ReportEntityPK (long lId) {
}
/**
* @roseuid 3DCB73B0007F
* @J2EE_METHOD -- ReportEntityPK
*/
public ReportEntityPK (long lId, java.sql.Timestamp tLastUpdated) {
}
/**
* @return the current value of the id property
* Access method for the id property
*/
public long getid() {
return id;
}
/**
* @param id the new value of the id property
* Sets the value of the id property
*/
public void setid(long id) {
this.id = id;
}
/**
* @return the current value of the lastUpdated property
* Access method for the lastUpdated property
*/
public Timestamp getlastUpdated() {
return lastUpdated;
}
/**
* @param lastUpdated the new value of the lastUpdated property
* Sets the value of the lastUpdated property
*/
public void setlastUpdated(Timestamp lastUpdated) {
this.lastUpdated = lastUpdated;
}
}
 
Roy Huang
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, That's whta I need...
Have a nice week,
Roy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!