I'm working with DataNucleus as part of a Google App Engine project and I'm having a bit of trouble with columns in persistence.
@PrimaryKey(column = "user_id")
@Column(name = "user_id")
@Persistent(name = "user_id", column = "user_id", valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key m_id;
@Column(name = "user_name")
@Persistent(name = "user_name", column = "user_name")
private String m_userName;
If you can't tell, I'm trying to name the column something different than the name of the variable because I have two naming conventions (one works better in Java, one works better in SQL). Anyway, I've tried all variations of those marker annotations but the DataNucleus enhancer refuses to honor any of them, so when I run a query like this:
Query q = pm.newQuery(User.class,
"user_name == _username");
I always get an error like this:
org.datanucleus.store.appengine.FatalNucleusUserException: Unexpected expression type while parsing query. Are you certain that a field named user_name exists on your object?
Of course, when a run a query like this:
Query q = pm.newQuery(User.class,
"m_userName == _username");
...everything just works great. So, there would be a field named user_name
if any of those annotations were honored, but they're clearly not.
SO my question is: Is there any way to decouple the tokens I use in the query from the name of the field? I'm looking for the ability to change the names of the fields without having to edit the queries by hand.
NOTE: I would sooner just use my SQL naming conventions in the Java classes than write the hideous amounts of XML by hand, so this has to be done with the annotations.