Bupjae Lee

Ranch Hand
+ Follow
since May 14, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Bupjae Lee

Then, can I write like this?



It doesn't seem to "straight" method, but I'll try it. Thanks.
6 years ago
For example, if I have Class object from array, I can get the component type of that array by writing this code:



The problem is, if I have some Class object, how can I make the Class object for array which component type is given.

For example, how can I make Object[].class from Object.class?
6 years ago
Because it is possible to have same timestamp for user-photo relationship,
I couldn't use Date as the key of map.

Instead, I decided to create a "mapping" entity like this, and it works perfectly.
Thanks for answering.



I want to make bidirectional ManyToMany relationship between PhotoInfo and UserInfo.
Moreover, I want to track when each PhotoInfo--UserInfo relationship is established.

However, this attempt fails with following exception:



How can I annotate this relationship properly?
Thanks in advance.
I wrote following JSF Facelet code:



But, NetBeans 7.0.1 says that "The required attribute name is missing" at line 2.
When I open this page with my browser, the inline script is worked correctly.

My question is, although my code works correctly, why my IDE complains?
7 years ago
JSF
I'm developing Swing application with JPA 2.0 (EclipseLink 2.0.2)
Since it is Java SE application, I can't use injection and/or JNDI

javax.swing.SwingWorker says:

Time-consuming tasks should not be run on the Event Dispatch Thread. Otherwise the application becomes unresponsive.
Swing components should be accessed on the Event Dispatch Thread only.


So, I use SwingWorker for time-consuming database access.
However, I'm not sure whether objects regarding EntityManager is thread-safe, and there are no "container" to manage them.

Question:
1. Can we use EntityManagerFactory object on many threads without explicit synchronize?
2. Can we use EntityManager object (for read-only) on many threads without explicit synchronize?
3. Is it "cheap" to make EntityManager object? (by emf.createEntityManager())
Is it "reasonable" to make EntityManager to invoke only one find operation and close it?


The result of i*i is int (may be converted to Integer), but you're trying to assing this value to a variable whose type is some subtype of Integer.
Like Integer x=new Object() is not allowed, this assignment is not allowed.
8 years ago
If that code were C++, it would work.
However, C++ template and Java generic is completely different.

In C++, when you type square<int>, the compiler makes the whole new class named square<int>
However, in Java, square<T> is just the only one square<T> class.

If you type public class square<T>, when you use object of type T in your square class,
you can use Object's methods only.

Likewise, if you type public class square<T extends Number>, only methods of Number are allowed.

For *, it is allowed for Integer, Float, Double, but not for Number or Object.
8 years ago
I think Effective Java Second Edition has good example.
You can check Sample chapter (Chapter 5) and read Item 23.
It explains why List<?> is safe and List is not safe.
8 years ago
Is following statement is ture?

This bug was happened because JRE couldn't decide whether value "2.2250738585072012e-308" is
"normalized value" or "de-normalized value".
8 years ago
Result:
2.2250738585072012e-308
2.2250738585072014E-308


After updating my JDK/JRE, program works well. Thanks all.

Campbell Ritchie wrote:Do you know what that value represents? Do you know its binary or hex format?



I don't know exactly... What I know is that float and double can't represent values exactly.
(for example, 1.03-0.97 is not exactly 0.06 for double)
8 years ago
The conclusion is: There is no wrong point in the code. All I have to do is update my JDK & JRE to the latest patch.
Is it right?

Christophe Verré wrote:Did you ask him where that value came from ?


He said he just found that number from the Internet.
8 years ago
My friend gave me following program and said it doesn't work



When I ran this program, after first println, my program didn't respond, didn't print message (including error message), didn't terminate.
I can't find what is wrong in this program, and I want to spot what and where the bug is.

Thanks in advance.
8 years ago
Actually, what I want to do is putting entities to another entity's Set.

However, because of problem I mentioned, I'm using List instead of Set.
I googled how to implement equals and hashCode for entity class.

There are some advices, but I'm still not sure which is the best solution.

1) Check only @Id field
Drawback: Before persisting, @Id field is null; in this case, there are no way to check equality

2) Check"business identity fields" that won't be changed
Drawback: There is some possiblity that such fields would be changed.

3) Build identity by programmer, not framework
Drawback: It is hard to make unique identity at any situation

Which is better choice? Any other suggestions?