Juan Tamayo

Greenhorn
+ Follow
since Mar 18, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juan Tamayo

There are several reasons behind my solution:

1. I don't want to store the Ordinal in the DB because it is too brittle: I can ruin my data by only rearranging the constants, or by adding another one in the middle of the existing ones.
2. I don't want to store the entire enum name because it might change (a refactoring, for example, to make the code clearer) and because it might be too long (VISIT_SCHEDULING_PENDING, for example).

I think this way the names in Java are clear, and the constants in the DB are short.

Regards,

Juan M
Hello everyone,

I have been trying to store a Java enum in my database using JPA/EclipseLink. After looking through many options, none of which seems to be "perfect" I thought a small trick might work. I can create an enum with "two" representations: a short one to store in the DB and a descriptive one to use in my code. It would be something like this:



Then I can annotate my persistent fields like this:



so I can store "CR" in the DB, and write something like this in my Java code:



Is this a dumb idea? Will it explode a year from now? I think it covers many cases except the switch statement, where the compiler complains because Status.CREATED is not a constant (which I think it is).

Thanks for your suggestions!!

Juan M
You're right, they're all synchronized. Thanks for the help!
Hello everyone,

I'm writing a simple Handler for the java logging API, so that I can write log messages using JDBC. I found an example in

http://www.developer.com/java/article.php/1468351

which is precisely what I need, except that it has no mention to concurrency issues. My question is, should a Handler object be thread safe? if so, which methods can be called from multiple threads? or are all calls made to a Handler object made from the same thread?

Thanks for your help,

Juan Tamayo
Hi,

I had a (for now) useless question. What happens with the instance variables of an enum when an object referring to that enum is serialized?

Thanks
16 years ago
The problem here is that unless I override the method in the Legacy class, the Outback class will not have access to the goFast() method in Legacy
[ March 18, 2007: Message edited by: Juan Tamayo ]
What happens when a subclass outside the package of the superclass overrides a protected method of it's superclass? According to what I see in the following code, the method becomes visible to all classes in the same package as the subclass.



The code compiles and runs OK. Then the question is, am I not breaking the whole purpose of "protected"?