sunse
asked on
Syntax error ")", delete this token, Syntax error: include enumBody to complete block statements, Syntax error: include enum Identifier to complete enumHeader
The method below causes the following errors:
Syntax error ")", delete this token, Syntax error: include enumBody to complete block statements, Syntax error: include enum Identifier to complete enumHeader. This is a method copied from the book Enterprise JavaBeans 3.0 and it occurs in all the instances where I use a JoinColumns in a JoinTable annotation (one to meny, many to many..) What might be causing it? I am pasting the entire class definition follwoing the method below
Thanks Sunse
@OneToMany(cascade={Cascad eType.ALL} )
@JoinTable(name="CUSTOMER_ PHONE"),
joinColumns={@JoinColumn(n ame="CUSTO MER_ID")},
inverseJoinColumns={@JoinC olumn(name ="PHONE_ID ")})
public Collection<Phone> getPhoneNumber()
{
return phoneNumbers;
}
package titan.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.*;
import titan.domain.CustomerType;
import titan.domain.Phone;
@Entity
@Table(name="CUSTOMER_TABL E")
public class Customer implements Serializable {
private int id;
private String firstName;
private String lastName;
private String street;
private String city;
private String state;
private CustomerType customerType;
private Address homeAddress;
private CreditCard creditCard;
private Collection<Phone> phoneNumbers = new ArrayList<Phone>();
@Id
@GeneratedValue
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
@Column(name="LAST_NAME")
public String getLastName()
{
return lastName;
}
public void setLastName(String last)
{
this.lastName = last;
}
@Column(name="FIRST_NAME")
public String getFirstName()
{
return firstName;
}
public void setFirstName(String first)
{
this.firstName = first;
}
@Enumerated(EnumType.STRIN G)
public CustomerType getCustomerType()
{
return customerType;
}
public void setCustomerType(CustomerTy pe type)
{
customerType = type;
}
@OneToOne(cascade={Cascade Type.ALL})
@PrimaryKeyJoinColumn
public Address getAddress(){
return homeAddress;
}
public void setAddress(Address address)
{
this.homeAddress = address;
}
@OneToOne(cascade={Cascade Type.ALL})
@JoinColumn(name="CREDIT_C ARD_ID")
public CreditCard getCreditCard()
{
return creditCard;
}
public void setCreditCard(CreditCard card)
{
this.creditCard = creditCard;
}
@OneToMany(cascade={Cascad eType.ALL} )
@JoinColumn(name="CUSTOMER _ID")
public Collection<Phone> getPhoneNumbers(){
return phoneNumbers;
}
public void setPhoneNumbers(Collection <Phone> phones)
{
this.phoneNumbers = phones;
}
@OneToMany(cascade={Cascad eType.ALL} )
@JoinTable(name="CUSTOMER_ PHONE"),
joinColumns={@JoinColumn(n ame="CUSTO MER_ID")},
inverseJoinColumns={@JoinC olumn(name ="PHONE_ID ")})
public Collection<Phone> getPhoneNumber()
{
return phoneNumbers;
}
}
Syntax error ")", delete this token, Syntax error: include enumBody to complete block statements, Syntax error: include enum Identifier to complete enumHeader. This is a method copied from the book Enterprise JavaBeans 3.0 and it occurs in all the instances where I use a JoinColumns in a JoinTable annotation (one to meny, many to many..) What might be causing it? I am pasting the entire class definition follwoing the method below
Thanks Sunse
@OneToMany(cascade={Cascad
@JoinTable(name="CUSTOMER_
joinColumns={@JoinColumn(n
inverseJoinColumns={@JoinC
public Collection<Phone> getPhoneNumber()
{
return phoneNumbers;
}
package titan.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.*;
import titan.domain.CustomerType;
import titan.domain.Phone;
@Entity
@Table(name="CUSTOMER_TABL
public class Customer implements Serializable {
private int id;
private String firstName;
private String lastName;
private String street;
private String city;
private String state;
private CustomerType customerType;
private Address homeAddress;
private CreditCard creditCard;
private Collection<Phone> phoneNumbers = new ArrayList<Phone>();
@Id
@GeneratedValue
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
@Column(name="LAST_NAME")
public String getLastName()
{
return lastName;
}
public void setLastName(String last)
{
this.lastName = last;
}
@Column(name="FIRST_NAME")
public String getFirstName()
{
return firstName;
}
public void setFirstName(String first)
{
this.firstName = first;
}
@Enumerated(EnumType.STRIN
public CustomerType getCustomerType()
{
return customerType;
}
public void setCustomerType(CustomerTy
{
customerType = type;
}
@OneToOne(cascade={Cascade
@PrimaryKeyJoinColumn
public Address getAddress(){
return homeAddress;
}
public void setAddress(Address address)
{
this.homeAddress = address;
}
@OneToOne(cascade={Cascade
@JoinColumn(name="CREDIT_C
public CreditCard getCreditCard()
{
return creditCard;
}
public void setCreditCard(CreditCard card)
{
this.creditCard = creditCard;
}
@OneToMany(cascade={Cascad
@JoinColumn(name="CUSTOMER
public Collection<Phone> getPhoneNumbers(){
return phoneNumbers;
}
public void setPhoneNumbers(Collection
{
this.phoneNumbers = phones;
}
@OneToMany(cascade={Cascad
@JoinTable(name="CUSTOMER_
joinColumns={@JoinColumn(n
inverseJoinColumns={@JoinC
public Collection<Phone> getPhoneNumber()
{
return phoneNumbers;
}
}
InverseJoinColumn (line 4) seems to have an extra right paren.
ASKER
Thank you Kdo, Yes you are right; but when I remove the paren, still get the same error message. I wonder if this is an Eclipse bug and there is any work around it.
Sunse
Sunse
The same error appears to happen about 6 lines from the bottom, too. Is that another spot that need correcting or a cut&paste error?
You might change the parameter name in setAddress. Using a data type name as a value name can cause parse issues.
public void setAddress(Address address)
{
this.homeAddress = address;
}
becomes
public void setAddress(Address addressValue)
{
this.homeAddress = addressValue;
}
Kent
You might change the parameter name in setAddress. Using a data type name as a value name can cause parse issues.
public void setAddress(Address address)
{
this.homeAddress = address;
}
becomes
public void setAddress(Address addressValue)
{
this.homeAddress = addressValue;
}
Kent
ASKER
I will be in touch with a reply
ASKER
Hi All,
I am still stack on the same problem
@ManyToMany
@JoinTable(name="RESERVATI ON_CUSTOME R"), //Syntax error on token (","), invalid type
joinColumns={@JoinColumn(n ame="RESER VATION_ID" )}, //Multiple markers at this line. Synta //error, insert enum identifier to complete Enum header
inverseJoinColumns={@JoinC olumn(name ="CUSTOMER _ID")}//My tiple markers at this line, syntax //error, insert EnumBody to to complete block statement. Syntax error, insert enum identifier to complete Enum Header. Syntax erro insert ; to complete field declaration
public Set<Customer> getCustomers()
{
return customers;
}
Thank you,
Sunse
I am still stack on the same problem
@ManyToMany
@JoinTable(name="RESERVATI
joinColumns={@JoinColumn(n
inverseJoinColumns={@JoinC
public Set<Customer> getCustomers()
{
return customers;
}
Thank you,
Sunse
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Because I found the solution.