This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preventing the hard-coding of an annotation

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have an JPA entity which is as follows:



I would like for "mySchema" to be located somewhere else and avoid the hard-coded variable. Can it be a constant located somewhere else? Can it be retrieved from a web context param? How do I move it somewhere else bearing in mind it is not located "within" the class and let alone within a method?

Do you see my problem? Any solution?

Julien.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

(have you tried?)

also, you can configure this information in XML, so have differing development and deployment environments without recompiling code
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bill,
Yes I tried that:

in my imports and that:

instead of that

and I get that:
attribute value must be constant
Any idea?
Julien.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems I can only use compile-time constants and not runtime constants. Is that really the case? Any workarounds?
Julien.
 
O Pang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I had the same issue in trying to get around compile-time constants. Try declaring your variable not just as static, but also as final... i.e.

public static final TEMP = "mySchema.Customer"

Later, O.
[ January 21, 2008: Message edited by: O Pang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic