Google App Engine JDO how to define class fields ?
- by Frank
I have a class like this :
import java.io.*;
import java.util.*;
public class Contact_Info_Entry implements Serializable
{
public static final long serialVersionUID=26362862L;
String Contact_Id,First_Name="",Last_Name="",Company_Name="",Branch_Name="",Address_1="",Address_2="",City="",State="",Zip="",Country="",E_Mail="",Phone;
int I_1,I_2;
float F_1,F_2;
boolean B_1,B_2;
GregorianCalendar Date_1, Date_2;
Vector<String> A_Vector=new Vector<String>();
public Contact_Info_Entry() { }
......
}
If I want to translate it to a class for JDO, do I need to define each field by it self or can I do a group at a time ?
For instance do I have to make it like this :
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Contact_Info_Entry implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
public static final long serialVersionUID=26362862L;
@Persistent
String Contact_Id;
@Persistent
String First_Name;
@Persistent
String Last_Name;
......
@Persistent
int I_1;
@Persistent
int I_2;
...
@Persistent
float F_1;
...
@Persistent
boolean B_1;
@Persistent
boolean B_2;
@Persistent
GregorianCalendar Date_1;
...
@Persistent
Vector<String> A_Vector=new Vector<String>();
public Contact_Info_Entry() { }
......
}
Or can I do a group at a time like this :
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Contact_Info_Entry implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
public static final long serialVersionUID=26362862L;
@Persistent
String Contact_Id,First_Name,Last_Name="";
......
@Persistent
int I_1=0,I_2=1;
...
@Persistent
float F_1;
...
@Persistent
boolean B_1,B_2;
@Persistent
GregorianCalendar Date_1;
...
@Persistent
Vector<String> A_Vector=new Vector<String>();
public Contact_Info_Entry() { }
......
}
Or can I skip the "@Persistent" all together like this :
import java.io.*;
import java.util.*;
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Contact_Info_Entry implements Serializable
{
public static final long serialVersionUID=26362862L;
String Contact_Id,First_Name="",Last_Name="",Company_Name="",Branch_Name="",Address_1="",Address_2="",City="",State="",Zip="",Country="",
E_Mail="",Phone;
int I_1,I_2;
float F_1,F_2;
boolean B_1,B_2;
GregorianCalendar Date_1, Date_2;
Vector<String> A_Vector=new Vector<String>();
public Contact_Info_Entry() { }
......
}
Which are correct ?
Frank