When to use EntityManager.find() vs EntityManager.getReference() with JPA

I usually use getReference method when i do not need to access database state (I mean getter method). Just to change state (I mean setter method). As you should know, getReference returns a proxy object which uses a powerful feature called automatic dirty checking. Suppose the following public class Person { private String name; private … Read more

What is the difference between Eclipse for Java (EE) Developers and Eclipse Classic?

If you want to build Java EE applications, it’s best to use Eclipse IDE for Java EE. It has editors from HTML to JSP/JSF, Javascript. It’s rich for webapps development, and provide plugins and tools to develop Java EE applications easily (all bundled). Eclipse Classic is basically the full featured Eclipse without the Java EE … Read more

How to create and handle composite primary key in JPA

You can make an Embedded class, which contains your two keys, and then have a reference to that class as EmbeddedId in your Entity. You would need the @EmbeddedId and @Embeddable annotations. @Entity public class YourEntity { @EmbeddedId private MyKey myKey; @Column(name = “ColumnA”) private String columnA; /** Your getters and setters **/ } @Embeddable … Read more

Difference between an application server and a servlet container?

A servlet-container supports only the servlet API (including JSP, JSTL). An application server supports the whole JavaEE – EJB, JMS, CDI, JTA, the servlet API (including JSP, JSTL), etc. It is possible to run most of the JavaEE technologies on a servlet-container, but you have to install a standalone implementation of the particular technology.

How to generate JAXB classes from XSD?

XJC is included in the bin directory in the JDK starting with Java SE 6. For an example see: http://blog.bdoughan.com/2010/09/processing-atom-feeds-with-jaxb.html The contents of the blog are the following: Processing Atom Feeds with JAXB Atom is an XML format for representing web feeds. A standard format allows reader applications to display feeds from different sources. In … Read more

Where to use EJB 3.1 and CDI?

Yes, you can freely mix both CDI and EJB and achieve some great results. It sounds like you are using @WebService and @Schedule, which are good reasons for adding EJB to the mix. There’s a lot of confusion out there, so here is some general information on EJB and CDI as they relate to each … Read more

Would you, at present date, use JBoss or Glassfish (or another) as Java EE server for a new project? [closed]

I have used WebLogic, WebSphere, JBoss, GlassFish, Resin, Jetty, Tomcat, and a few others over the last 10+ years. So, if I were considering a new project, I would ask myself a few questions first. One thing that I would not question anymore is that I would flat refuse to use JSPs unless I was … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)