Java
Be aware of Mutliple Result Mappings in JPA!
0Recently at work, i came across an issue when using @SqlResultSetMapping from JPA (Java Persistence API) to build native queries retrieving result from multiple entities at once. The problem was actually due to a naive usage from me of those result set mappings, in particular when my queries were returning multiple entities with same column names. It took me a little while to figure out what the problem was, so that I thought i would share this experience with you:
The problem:Let’s say you have two classes: “Person” and “Car” defined as such:
Person.java:
import More >
Use JAX-RS to create a file download web service
0Until now, when i needed to download a file from Server, i systematically ended up writing a Java Servlet, and overriding its doGet() method.In this method, i first retrieved and checked the request’s parameters. if they were not valid, i threw a exception , otherwise, i used them to fetch the file to download.Then, i opened an output stream down to the HTTP Response, and i manualy copied the file to it, bytes by bytes.
Code sample:
public class FileDownloadServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse More >
Create RIA Applications in Java with GWT
0Haven’t you always wanted to create Rich Internet Applications (RIA) in Javascript/AJAX but renounced to do so because you don’t know anything about these technologies ? Or you do know AJAX, but managing a code that will work for every web browser out there just drive you nuts. Besides, you find writing a non-trivial Javascript application very painful, given that you can’t debug your program, watch variables, find some errors without running the code, and the list continues. You know very well Java , and has been seduced by it since your write your first “Hello World” program ?
Well,
More >
Manage your Java projects with Maven
2There is nothing more irritating than working on a Java project that implies one or more libraries. You need to find and add to your class path, every single *.jar file required by each of them. Sometimes, different libraries rely on the same subsets, but use different versions. So to avoid conflicts, you need to find the right versions that work for all of them.
A typical example, is a web application involving Struts, Hibernate, and Spring. It can be a real nightmare to find out the correct set of *.jar files that will make those three frameworks happy. I’m not saying it’s impossible,
More >