java

simple hibernate session management

hello good people! i'm a bit new in the world of hibernate and i lack knowledge in certain domain when it comes to java.I know for a fact that a good piece of software that uses hibernate use a session manager that can provide different kind of session.i'll like to create for now a simple session manager on top of which i'll build gradua...

How to best test Java code?

I have been working on a comparatively large system on my own, and it's my first time working on a large system(dealing with 200+ channels of information simultaneously). I know how to use Junit to test every method, and how to test boundary conditions. But still, for system test, I need to test all the interfacing and probably so some s...

When it comes to regex, what is the difference between `Greedy` and `Reluctant` quantifiers?

From the Pattern javadocs: Greedy quantifiers: X? X, once or not at all X* X, zero or more times X+ X, one or more times X{n} X, exactly n times X{n,} X, at least n times X{n,m} X, at least n but not more than m times Reluctant quantifiers: X?? X, once or not at all X*? X, zero or more times X+...

Consuming a WCF WsHttpBinding WebService in Java

Hey guys, I'm trying to get a Java Client to communicate with a WCF wshttpbinding WebService. But I am unable to do so. The call either hangs, or I get "musunderstoodheader expcetions". My Web Service is just the default Visual Studio generated "WCF Service Library Template". My Web Service Client is just a blank IntelliJ project, wi...

Check if a dll library is already loaded? (Java)

Hey Folks, In a Java program i am writing i make a jni call to a dll and load the library on startup as follows static { System.loadLibrary("LdapAuthenticator2"); } I then implemented another class that loads the same library and am getting an error saying that the library is already loaded, is there any way to check if the librar...

How to know what made a hibernate persisted object dirty?

An object I mapped with hibernate has strange behavior. In order to know why the object behaves strangely, I need to know what makes that object dirty. Can somebody help and give me a hint? The object is a Java class in a Java/Spring context. So I would prefer an answer targetting the Java platform. Edit: I would like to gain access t...

Java Servlet/JSP Cookie Disconnect

Hey guys. I'm having a strange issue with cookie visibility between an authentication servlet and our actual jsp. We're using a servlet to authenticate that the user is a valid user, and if they are, we go ahead and add a cookie to the HttpServletResponse with their referer url (this is so that integrations can be redirected to their ow...

How can you replicate Hibernate's saveOrUpdate in JPA?

In JPA, is there any way you can replicate Hibernate's saveOrUpdate behavior, saveOrUpdate public void saveOrUpdate(Object object) throws HibernateException Either save(Object) or update(Object) the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-val...

different configuration files for different server.

Hi How would you solved that? I have one application in which I have a few configuration files, I make war file and deploy it on the tomcat. But at the same time I have to make the war file and deploy the same application under different context and/or a server with modified configuration files. I can create my own task in ant, and ...

Detect internet Connection using Java

I want to see if anyone has an easy way of detecting if there is an internet connection when using Java. The current app used the "InternetGetConnectedState" method in the WinInit DLL for windows, but my app needs to be cross-platform for mac operation and this way will not work. I do not know JNI at all either to use DLLs in Java and it...

Loading javassist-ed Hibernate entity

I have a JSF converter that I use for a SelectItem list containing several different entity types. In the getAsString() method I create the string as the class name suffixed with ":" and the ID. MySuperClass superClass = (MySuperClass)value; if(superClass != null) { return String.valueOf(superClass.getClass().getName()+":"+superClass...

Maintaining Eclipse project include/lib paths in CVS

Background: Here at the office my group uses a common linux environment where we do our code development. Our code is kept in CVS. The latest releases of our various libraries are kept in a specific directory (ie /data/group_projects/lib). Our Makefiles/Ant builds all specify what libraries are needed. We use autoconf to create the make...

Use Grizzly transparently under the hood?

Is there a way to bind grizzly dynamic/transparent to my Java Applications (maybe by using spring)? Or is the IO handling part of the Web Container (eg. Glassfish)? ...

Help: Java web app framework like ASP.Net

Can anyone suggest a Java Web Application framework something like ASP.Net? Thanks. ...

SCJP Question: Handle Exceptions

Hi, I'm studying for Java Programmer Certification (SCJP) exam. A question about exceptions, when handle exceptions is it best to handle a specific exception like NumberFormatException or catch all exceptions use the parent Exception class? Base on my course unchecked exceptions are basically a RunTimeException which mostly result of a ...

How to include restricted fileset in zip without creating an interim copy in ant

I have a fileset which contains a number of jars of which I only want a subset. I'm currently doing this: <target name="work-around"> <delete dir="${dir.deps}" failonerror="false" /> <copy todir="${dir.deps}" flatten="true"> <restrict> <fileset refid="mvn.deps.fileset" /> <rsel:name name="**/mycompany-core*...

Read and parse KML in java

Hi Is there any library available to parse KML ? ...

Java output a file to the screen

I know this is a little broad, but here's the situation: I am using JSP and Java. I have a file located on my server. I would like to add a link to the screen that, when clicked, would open the file for the user to view. The file can either appear in a window in the web browser, or pop up the program needed to open the file (similar ...

How to escape a square bracket for Pattern compilation

Hello guys. am new to regular expression. I have comma seperated list of regular expressions like: .{8},[0-9],[^0-9A-Za-z ],[A-Z],[a-z]. I have done a split on the comma. Now am trying to match of this regex against a generated password. The problem is that Pattern.compile does not like square brackets that is not escaped. Can some plea...

Java Swing Range Slider U.I.

Hello. I needed a slider with two knobs on it (representing a range) and I found this nifty one here. However, they created their own U.I. which extends Java's BasicSliderUI. They override the paint method to draw their own knobs. I would like to use the default knobs based on the current look and feel. I tried calling BasicSliderUI...