java

Looking for *working* Hibernate examples

I have been scouring the intertubes for working somewhat recent Hibernate examples. I understand it well on a conceptual level, but I'm having trouble throwing together a "hello world" program, because every one I find doesn't build for me. I should be able to adapt to different entity relationships after that, but I would settle for a...

Is there a way to define 'javadoc types' - custom parameters for members?

The use case I can think of is the following: In a typical application, there are usually many members of a certain category, e.g., a web application contains many constants attribute keys, Action classes, services, etc. For each category, to maintain consistency, it is useful to document them consistently. Consider the constants used ...

Apache Commons Fileupload / Tomcat cant cope with out.flush()

Does anyone know of a workaround whereby if you are trying to flush the servlet output stream, apache commons fileupload throws the following exception? FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly Basically I have code that loops through each file uploaded using apache commons fileu...

How do I convert a byte to a long in Java?

I am reading 8 bytes of data in from a hardware device. I need to convert them into a numeric value. I think I want to convert them to a long as that should fit 8 bytes. I am not very familiar with Java and low level data type operations. I seem to have two problems (apart from the fact there is almost no documentation for the hardwar...

What is the best way to call repaint() at regular intervals in my Java2D program?

I'm looking to call repaint() in my Java2D simulator at regular intervals. What would be the best way to do this? Should I start another thread and have a loop that keeps track of currentTimeMillis()? Or is there a better way? ...

eclipse 3.4 can't start

Yesterday, I try to start eclipse 3.4 by click eclipse.exe (in eclipse folder), and run normally. Then yesterday night, I do windows update. Today, when I try to run eclipse 3.4, it has error. The error message you can find at here SCREENSHOT I use windows xp sp2, and java 1.5 update 14. I don't know how to fix that, so I uninstalled ...

java.lang.OutOfMemoryError: Java heap space in jasper report

When i export content in doc format then i get java heap space error, java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at java.io.ByteArrayOutputStream.write(Unknown Source) at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source) at sun.nio.cs.StreamEncoder.implWrite(Unknown Source) ...

alignment in applet

how can we align the variois interface component(such as label, textfield, button) in applet?? As for instance i want 4 label and a button in an applet, in which all the component should be in different line?? how can we do it?? ...

are there some libraries like java httpclient in ruby

hi all, i want to know whether there are libraries like java httpclient in ruby? great thanks. ...

Tell SAX Parser to ignore invalid characters?

SAX keeps on dying on the following exception: Invalid byte 2 of 3-byte UTF-8 sequence The problem is its mostly correctly UTF-8 encoded but there are a few errors in it. We cannot get a new version of the file, we have to use this file. So how do we tell SAX to ignore invalid character sequences, or clean up the UTF-8 file so that i...

How do I do double buffering in Java2D?

I'm drawing a bunch of primitives using Java2D on the screen and I'm getting a lot of tearing/flicker. How can I enable/use double-buffering so it draws it off screen then shows the whole thing? ...

Mocking inter-method dependencies

I've recently started using mock objects in my tests, but I'm still very inexperienced with them and unsure of how to use them in some cases. At the moment I'm struggling with how to mock inter-method dependencies (calling method A has an effect on the results of method B), and whether it should even be mocked (in the sense of using a mo...

File locking (read/write) in Java

I'm writing something to handle concurrent read/write requests to a database file. ReentrantReadWriteLock looks like a good match. If all threads access a shared RandomAccessFile object, do I need to worry about the file pointer with concurrent readers? Consider this example: import java.io.FileNotFoundException; import java.io.IOExc...

How to create a temporary jms queue and connect to it by name?

I need to create a temporary queue for responses, but I need to know if it is possible to connect to temporary queue without sending response queue object via setJMSReplyTo method of message, because replying thread doesn't get that object at all. ...

OSGi: Does Blueprint replace Declarative Services?

The new R4.2 spec for OSGi describes the Blueprint service, for dependency injection and service wiring. Does Blueprint replace Declarative Services (which is still part of the spec, as well), or are they intended to work together? Is Blueprint already available for the popular implementations (Felix and Equinox)? ...

Is it possible to exclude some targets from Ant targets while executing the script?

In ant if want to execute more than one target, we can do it like this, ant target1 target2 target3 Other way could be, create target4 like <target name="target4" depends="target1,target2,target3" /> but the problem is, one of my target definition is: <target name="buildApp" depends="init,copy-all-requiredfiles-local,wait-to-merge...

Spring not restoring tomcat persistent sessions to session registry after restart?

I'm using Tomcat 6.2 and Spring MVC 2.5. I've noticed that, whilst a user is logged in I can restart Tomcat and the user is able to continue browsing without re-authenticating. This appears to be coming from Tomcat's ability to persist sessions across restarts. It appears, however, that these persisted sessions do not make it back into ...

Localization of default messages in JavaServer Faces

Hi, I'm trying to set up a norwegian version of a site built with JSF. I know how to display my own messages based on what locale is set to, but I'm having trouble with the default messages (eg. when a form input is invalid). As far as I can tell, norwegian is not supported. Does anyone know how I could overcome this? e.g. by translatin...

INSERT LOW_PRIORITY or INSERT DELAYED in Hibernate

Hi guys, How do I do a low_priority or delayed insert into a MySQL table with Hibernate? In my logging routine I want to insert the log info to a table in my database for further analysis. But I don't care about how long it takes for the insert to be done, so usually I would say INSERT LOW_PRIORITY INTO LogEntry (level, title, full) VA...

Inherited method needs one more parameter

I have a parent class with several children. One of the children, has one overridden method that, for its particular internal usage, needs one more parameter. I don't want to change the method's signature because the overridden method in the other children does not need this parameter, also, I don't want to add a class property because i...