can I have both JDO and JPA annotations at the same time?
What will actually happen if I provide a full set of annotations for JPA and JDO on data objects?
Can I then switch between them without touching the code? how can I switch what to aplay external configuration files? I know in the META-INF 开发者_开发知识库there are persistence.xml jdoconfig.xml but I do not understand the how to use them. (may be a link to a compressive explanation?) Currently I got both files in place and the code below compiles Ok. I am interested in what goes under the hood to understand implications of this approach.
For vivid example:
@Entity
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
class B
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Persistent
@Basic
private String name;
}
Platform: default setup of Google AppEngine 1.4 it uses DataNucleus Enhancer (version 1.1.4)
Although I have never try this it should work. This is the point of annotations: the do not affect the code unless they are used. JPA implementation uses its annotations, JDO uses others.
精彩评论