use java.lang.Integer instead of int. > -----Original Message----- > From: Lauren Commons [mailto:[EMAIL PROTECTED]] > Sent: Thursday, June 29, 2000 6:03 PM > To: [EMAIL PROTECTED] > Subject: Re: How to create SQL statements within J2eeSdk if there > isnoPrim ary Key? > > > I assume the String in > > <prim-key-class>java.lang.String</prim-key-class> > corresponds to a char-type field in the database. > What if the primary key in the database table is not a > string? I have int fields, for instance. > > it also works with cmp. If you don't have a compound key > there is no need > > for an extra PK class > > > > <entity> > > <description /> > > <display-name /> > > <small-icon /> > > <large-icon /> > > <ejb-name>StructureFolder</ejb-name> > > <home>com.ceag.dms.server.StructureFolderHome</home> > > <remote>com.ceag.dms.server.StructureFolder</remote> > > <ejb-class>com.ceag.dms.server.StructureFolderBean</ejb-class> > > <persistence-type>Container</persistence-type> > > <prim-key-class>java.lang.String</prim-key-class> > > <reentrant>False</reentrant> > > <cmp-field> > > <description /> > > <field-name>path</field-name> > > </cmp-field> > > <cmp-field> > > <description /> > > <field-name>description</field-name> > > </cmp-field> > > <cmp-field> > > <description /> > > <field-name>name</field-name> > > </cmp-field> > > <cmp-field> > > <description /> > > <field-name>oid</field-name> > > </cmp-field> > > <primkey-field>oid</primkey-field> > > <ejb-ref> > > <description /> > > <ejb-ref-name>ejb/docspace</ejb-ref-name> > > <ejb-ref-type>Entity</ejb-ref-type> > > <home>com.ceag.dms.server.DocSpaceHome</home> > > <remote>com.ceag.dms.server.DocSpace</remote> > > <ejb-link>DocSpace</ejb-link> > > </ejb-ref> > > <resource-ref> > > <description /> > > <res-ref-name>StructureFolderDB</res-ref-name> > > <res-type>javax.sql.DataSource</res-type> > > <res-auth>Container</res-auth> > > </resource-ref> > > </entity> > > > > Ulf Gohde > > > > > > > -----Original Message----- > > > From: Stefan Hanenberg �mailto:shanenbe�INFORMATIK.UNI-ESSEN.DE� > > > Sent: Thursday, June 29, 2000 4:30 PM > > > To: EJB-INTEREST�JAVA.SUN.COM > > > Subject: Re: How to create SQL statements within J2eeSdk if there > > > isnoPrimary Key? > > > > > > > > > Hi Nail, > > > > > > thank you for your answer...but maybe I have to add that > my Bean is a > > > container-managed one (sorry, I forgot to say). > > > > > > Stefan > > > > > > > > > > > > "Nail A." schrieb: > > > > > > > > Hi Stefan, > > > > at first: the finder methods are defined in the home-interfaces > > > > (see section 8.3.2 of the EJB-Spec.1.1.) > > > > > > > > for example: > > > > public Account findByPrimaryKey(String user_id) > > > > throws FinderException, RemoteException; > > > > public Collection findByLastName(String name) > > > > throws FinderException, RemoteException; > > > > public Collection findInRange(double low, double high) > > > > throws FinderException, RemoteException; > > > > > > > > The Entity-EJB has to define one ejbFind�...�-method for > > > each of this methods. > > > > That means, that this methods contain calls to special > methods with > > > > SQL-Queries. > > > > > > > > example: > > > > > > > > public String ejbFindByPrimaryKey(String primaryKey) > > > > throws FinderException > > > > � > > > > System.out.println("ejbFindByPrimaryKey method"); > > > > try � > > > > if (selectByPrimaryKey(primaryKey)) � > > > > return primaryKey; > > > > � > > > > else � > > > > throw new ObjectNotFoundException > > > > ("Row for id " + primaryKey + " not found."); > > > > � > > > > � catch (Exception ex) � > > > > throw new EJBException("ejbFindByPrimaryKey: " + > > > > ex.getMessage()); > > > > � > > > > � > > > > > > > > last but not least: > > > > > > > > private boolean selectByPrimaryKey(String > primaryKey) throws > > > > java.sql.SQLException > > > > � > > > > System.out.println(" selectByPrimaryKey method"); > > > > String selectStatement = "SELECT ID FROM TABLE > > > WHERE USER_ID = ? "; > > > > PreparedStatement prepStmt = > > > > (PreparedStatement)con.prepareStatement(selectStatement); > > > > prepStmt.setString(1, primaryKey); > > > > prepStmt.executeQuery(); > > > > ResultSet rs = (ResultSet)prepStmt.executeQuery(); > > > > boolean result = rs.next(); > > > > prepStmt.close(); > > > > return result; > > > > � > > > > > > > > Hope, this helps you to solve your problems. > > > > regards > > > > Nail > > > > - Dep.of CS - > > > > Univ. Hamburg > > > > > > > > > > > ************************************************************** > > > ***************************** > > > > > > > > Stefan Hanenberg wrote: > > > > > > > > > Hi, > > > > > > > > > > I have a question: I have an EntityBean without a primary > > > key-class. How > > > > > can I use it within the j2eesdk and cloudscape? The main > > > problem is: > > > > > What are the SQL-statements for ejbRemove() and > > > findByPrimaryKey()? > > > > > > > > > > Regards, > > > > > Stefan > > > > > > > > > > > > > ============================================================== > > > ============= > > > > > To unsubscribe, send email to listserv�java.sun.com and > > > include in the body > > > > > of the message "signoff EJB-INTEREST". For general help, > > > send email to > > > > > listserv�java.sun.com and include in the body of the > > > message "help". > > > > > > > > > > > ============================================================== > > > ============= > > > > To unsubscribe, send email to listserv�java.sun.com and > > > include in the body > > > > of the message "signoff EJB-INTEREST". For general help, > > > send email to > > > > listserv�java.sun.com and include in the body of the > message "help". > > > > > > -- > > > *************************************************************** > > > Dipl.-Wirt.Inform. Stefan Hanenberg > > > Mathematics & Computer Science > > > University of Essen > > > Sch�tzenbahn 70 > > > D-45117 Essen > > > Germany > > > > > > email: mailto:shanenbe�informatik.uni-essen.de > > > www: http://www.cs.uni-essen.de/shanenbe/ > > > phone: ++49-201-183-2168 > > > fax: (+49) 201-183 2419 > > > *************************************************************** > > > > > > ============================================================== > > > ============= > > > To unsubscribe, send email to listserv�java.sun.com and > > > include in the body > > > of the message "signoff EJB-INTEREST". For general help, > > > send email to > > > listserv�java.sun.com and include in the body of the > message "help". > > > > > > > > ============================================================== > ============= > > To unsubscribe, send email to listserv�java.sun.com and > include in the body > > of the message "signoff EJB-INTEREST". For general help, > send email to > > listserv�java.sun.com and include in the body of the message "help". > > > > ============================================================== > ============= > To unsubscribe, send email to listserv�java.sun.com and > include in the body > of the message "signoff EJB-INTEREST". For general help, > send email to > listserv�java.sun.com and include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
