[JBoss-user] [Persistence & CMP/JBoss] - Re: Foreign Key is also Primary Key

2004-06-20 Thread loubyansky
Yes, you can. First, get familiar with ejb-jar.xml and mapping in jbosscmp-jdbc.xml.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839349#3839349

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839349


---
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence & CMP/JBoss] - Re: Foreign Key is also Primary Key

2004-06-19 Thread madadi
hai..

 Is it possible that i can use userid as a Primarykey for one table and Foreign key 
for other table.

because i have a one registration form which contains personal data and specific data. 
but both should store in 2 different table.

in my database i declared user id as a Primarykey for personal_data table and foreign 
key for specific_data table.

so what will be the solution ? i want to store data in both tables and retrieve info 
from both tables.

regards
madadi


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839328#3839328

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839328


---
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence & CMP/JBoss] - Re: Foreign Key is also Primary Key

2004-06-19 Thread loubyansky

  |  
  | userid
  | java.lang.String
  |  
  | 

This is not going to work. A field can't be both CMP and CMR at the same time. And 
from ejb-jar_2_0.dtd


  | 
  | 
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839306#3839306

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839306


---
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence & CMP/JBoss] - Re: Foreign Key is also Primary Key

2004-06-18 Thread madadi
 Dear Alexey Loubyansky,

 I too having same problem actually i thought that i solved but it works due to i 
created another primary key in second table.

 userid is Primary key for One table and Foreign Key for 2nd table.I created the one 
more Primary key in second table(sem) than i can store info from registration form but 
when i want to use foreign key of second table to store info  it does't work.



Servlet Code:

 
 beanRemote = 
home.create(fname,lname,dob,sex,userid,password,street,city,zipc,phone,email );

db = home.findByPrimaryKey(userid);


beanRemotes = homes.create(userid,dept,mno,sem );

dbs = homes.findByPrimaryKey(sem);





private boolean checkUSERID ( String userid, InitialContext context )
 
throws NamingException {
Object object = context.lookup("RegistrationEjb");
RegistrationHome home = ( RegistrationHome )
PortableRemoteObject
   .narrow ( object, RegistrationHome.class ); 
 
   
try {
System.out.println("");
Registration data = home.findByPrimaryKey( userid );
if ( data!=null ) {
if ( data.getUserid().equals( userid ) ) {
return true;
}
} else {
return false;
}   

} catch ( Exception exception ) {
return false;
}   


return true;
}


private boolean checkSEM ( String sem, InitialContext context ) 

throws NamingException {
Object object = context.lookup("RegistrationspecificEjb");
RegistrationspecificHome home = ( RegistrationspecificHome )
PortableRemoteObject
   .narrow ( object, 
RegistrationspecificHome.class );  
   
try {
System.out.println("");
Registrationspecific data = home.findByPrimaryKey( sem );
if ( data!=null ) {
if ( data.getSem().equals( sem ) ) {
return true;
}
} else {
return false;
}   

} catch ( Exception exception ) {
return false;
}   


return true;
 }

ejb-code:

public interface RegistrationspecificHome extends EJBHome{

public static final String 
COMP_NAME="java:comp/env/ejb/madadi/Registrationspecific";

public static final String JNDI_NAME="ejb/madadi/RegistrationspecificEjb";

public Registrationspecific create(String userid,String dept,String mno,String 
sem) throws RemoteException, CreateException;
public Registrationspecific findByPrimaryKey(String sem) throws 
FinderException, RemoteException;
public Registrationspecific findAll() throws FinderException, RemoteException;





public interface RegistrationHome extends EJBHome{

public static final String COMP_NAME="java:comp/env/ejb/madadi/Registration";

public static final String JNDI_NAME="ejb/madadi/RegistrationEjb";

public Registration create(String fname, String lname, String dob, String sex, 
String userid, String password, String street, String city, String zipc, String phone, 
String email) throws RemoteException, CreateException;
public Registration findByPrimaryKey(String userid) throws FinderException, 
RemoteException;
public Registration findAll() throws FinderException, RemoteException;

}





public abstract class RegistrationspecificEjb implements EntityBean {


  
  public abstract String getUserid();   
   public abstract String getDept();
   public abstract String getMno();
   public abstract String getSem();
  
  public abstract void setUserid(String userid);
  public abstract void setDept(String dept);
  public abstract void setMno(String mno);
  public abstract void setSem(String sem);
  
  public String ejbCreate(String userid,String dept,String mno,String sem ) throws 
RemoteException, CreateException
  {


setUserid(userid);
setDept(dept);
setMno(mno);
setSem(sem);
   
   
return (null);

  }



public abstract class RegistrationEjb implements EntityBean {

//  Called by container after setEntityContext
// Use the abstract methods to set parameters


  public abstract String getFname();
  public abstract Strin

[JBoss-user] [Persistence & CMP/JBoss] - Re: Foreign Key is also Primary Key

2004-06-18 Thread loubyansky
Could you post the ejbCreate implementation, stacktrace and DDs?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839181#3839181

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839181


---
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user