Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365489

Summary: [Validation] Validation needed for incompatible access type
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: JPAAssignee: Neil Hauge <neil.hauge>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: neil.hauge
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Nan Li CLA 2011-12-02 16:21:02 EST
Build Identifier: I-3.4.0-20111117042436

Runtime complains incompatible access type under some cases when defining entities with field-based access on property or property-based access on field. Here are a couple of such cases:

Case 1:
@Entity
@Access(AccessType.FIELD)
public class Test implements Serializable {

	private int id;
	private static final long serialVersionUID = 1L;

	public Test() {
		super();
	}   
	
	@Id
	@Access(FIELD)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}
}

Case 2:
@Entity
@Access(AccessType.PROPERTY)
public class Test implements Serializable {

	   
	@Id
	@Access(AccessType.PROPERTY)
	private int id;
	private static final long serialVersionUID = 1L;

	public Test() {
		super();
	}   

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}
}

At least a warning message should be given to remind the potential problem during runtime. Please note that runtime won't complain once specifying property-based access to the property regardless what else is specified.

Reproducible: Always