As a best practice, you'll want to use a session factory. Here is the one Netbeans generates.
public class HibernateUtil {
private static final SessionFactory sessionFactory;
private static final Configuration configuration = new Configuration().configure();
static {
try {
...
@Wietlol Is it really the issue with sessions? I read somewhere that using CriteriaBuilder and CriteriaQuery I wouldn't have to worry about sessions and transactions.
@geisterfurz007 if you just used spring, you wouldnt have to worry about which database you have, how you use it, if there is a database, how you write your queries, with what driver you access a database, etc
Java needs tuples, or lightweight objects, and make everything an object-- make primitives an implementation detail. Java needs the ability to remove GC from Java 1.1 and allow Manual memory management.
Also, JS allows variables and declarations of non-class/interfaces outside classes. Writing private int x; in a Java file outside a class isn't allowed, but var x; in JS is. JS isn't compiled, Java is. JS implementations are browser-specific, where as Java is based on the version of JVM. JS in Chrome doesn't work the same way as JS in Firefox
@Wietlol outside classes or interfaces, Enums are classes extending Enum, @interfaces are basically interfaces. But you can't declare variables or methods at the top-level of files. At least in Java 8
Imagine interfaces that can be abstractly implemented... because pointers would stand for the objects... then we wouldn't need "public abstract class" declarations.
@Wietlol: interface: here's the general idea, now do it yourself; abstract class: here's the general idea, but these are the constraints, now do it yourself; public class: here's the implementation.
You can define an abstract class to constrain the implementation such that the implementation does not make new objects except by the abstract class, or you can define certain methods of the interface as final to further constrain, or make the constructors private, but have protected abstract <O> O initializer(O o); for initializing the class in a special way, such as through lazy initialization or through dependency injection in a secure manner...
classes will never be interfaces, even if they now look kinda similar with default methods. Abstract classes and interfaces are similar, but interfaces don't currently replace abstract classes.
Also, interfaces can't declare constructors. Keeping them separated is better than creating a mess where interfaces can declare constructors, which means they change state or some shit like that
Also, there really is nothing wrong to have something like "AbstractSet" since every Set is an AbstractSet most of the time and is a good skeletal implementation to remove the boilerplate of copying and pasting the same code which does the same thing, but with a different name, in perhaps a slightly different way...
@geisterfurz007 What is the error you get? It should be possible to deploy Hibernate with your application to have an upgraded version. Upgrading Wildfly is a bit drastic only to have access to one up to date library, it is better to be prepared with a plan B when the request is declined.
I tend to put the version that I see being put into my project using mvn dependency:tree, but for testing purposes it may be better to put the version that will be available at runtime yes.