java

Lazily loading a clob in hibernate

There's a lot one can find about this googling a bit but I haven't quite found a workable solution to this problem. Basically what I have is a big CLOB on a particular class that I want to have loaded on demand. The naive way to do this would be: class MyType { // ... @Basic(fetch=FetchType.LAZY) @Lob public String getBlob() ...

jdk versions

i develop java app in 2 different computers ( same souce-code) , which have different jdk versions. is there a way to specify jdk version in the source-code so that ide (e.g netbeans) compile the same source-code on both machines. To be clearer: jdk5: jdbc-interface doesnt support some methods (e.g NClob, XML...) which are available in ...

Type casting from an Object

I have some code in Java as follows: private Object addVertex(String label, int posX, int posY) { Vertex newVertex = new Vertex(); this.getModel().beginUpdate(); try { newVertex = insertVertex(parent, null, label, posX, posY, 80, 30); } finally { this.getModel().endUpdate(); } return newVertex; } That code wont work because...

Starting OpenOffice from applet

I have this code down and this working fine from command line ... But when I put this in applet I get following error com.sun.star.lang.IllegalArgumentException at com.sun.star.comp.bridgefactory.BridgeFactory.createBridge(BridgeFactory.java:158) at com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlResolver.jav...

Problem in interpreting dynamic attributes in Jsp

Hi, I'm trying to process dynamic attributes in Jsp, but I'm getting display nothing in response. Here's the JSP code: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="mine" uri="DiceFunctions" %> <html><body> <mine:advice suggest="yo haa haa" > </mine:advice> </body></html> The TLD file, whic...

Letting a Java Swing program layout itself again

I always have trouble with Java layouts, but the main thing bugging me now is that when the content changes, in particular changes it sizes, it's not laid out again properly. Take the example below: package layouttest; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swi...

How effective is executeBatch on a Prepared Statement?

Subject to this question, asks it all:How effective is executeBatch method? Is there a performance benchmark, that says.. 'if you have 1000 records to be inserted, using a executeBatch instead of executeUpdate saves you x amount of database cycles?' Or Is this just a convention? EDIT: Here is what I am working with: a DB2 V 8.1 hoste...

Code complexity analysis tools beyond cyclomatic complexity

While cyclomatic complexity is a worthwhile metric, I tend to find it to be a poor tool for identifying difficult to maintain code. In particular, I tend to find it just highlights certain types of code (e.g. parsers) and misses difficult recursion, threading and coupling problems as well as many of the anti-patterns that have been defi...

What causes a NullPointerException in the AWT-EventQueue-0 thread

I'm trying to do something to track down the problem, but there's not much I can do until paintContents, and everything there looks good through my debugger, but I'll double check to make sure I didn't miss anything. At the very least, I would like to know how to silently handle these (such as catching them and being able to output a mea...

Is there a Java API or built-in function for solving annuity problems?

I was asked by my boss to create a module for calculating reverse compound. The question is: if I want to achieve $1.000.000,00 in 24 months with interest rate 18%/year (or 1.5%/month). how much money do I have to save every month? I searched on the internet, but found nothing except people referring to the Excel formula. Do you know ...

Finding overriding methods

In Eclipse, can I find which methods override the method declaration on focus now? Scenario: When I'm viewing a method in a base class (which interface), I would like to know where the method is overriden (or implemented). Now I just make the method final and see where I get the errors, but it is not perfect. Note: I know about class ...

How to convert array of bytes into Image in Java SE

Hi, What is the right way to convert raw array of bytes into Image in Java SE. array consist of bytes, where each three bytes represent one pixel, with each byte for corresponding RGB component. Can anybody suggest a code sample? Thanks, Mike ...

How to use mock object mimicing a daily routine program?

My program has a daily routine, similar to an alarm clock event. Say, when it's 2pm(The time is the system time in my pc), do something for me. What I want to do is to speed up the testing period(I don't really want to wait 4 days looking at the daily routine and check errors.) I read on wiki of Mock object, the writer DID mention alar...

How can I fill out an online form with Java?

Howdy, My cell phone provider offers a limited number of free text messages on their website. I frequently use the service although I hate constantly having a tab open in my browser. Does anyone know/point me in the right direction of how I could create a jar file/command line utility so I can fill out the appropriate forms on the sit...

JProbe Snapshots and setting recodring level options

Hi there, I am trying to profile my java application with JProbe. I am little confused with Snapshots and 'Set Recording Level' options. I am not able to understand the relation between them. Can somebody please take pain to explain me or point to any online articles which can clarify my confusion. Thank you very much, Chaitanya ...

Diff between setLine() and setValue() in Ant API Commandline.Argument class?

I don't understand the difference between these methods. Here's what the JavaDoc says: setLine(String) = Line to split into several commandline arguments. setValue(String) = Sets a single commandline argument. My confusion is that I see them being used interchangeably in the code I'm updating. An example: Commandline comma...

In Need of Refactoring in Order to Improve Testability

Hi, I'm testing a simple DAO layer with mockito but I found a problem, basically a hard to test interface and I was wondering if you could give me some insight... This is the method I want to test: public Person getById(UserId id) { final Person person = new PersonImpl(); gateway.executeQuery(GET_SQL + id.getUserId(), new Resu...

when would CloneNotSupportedException be thrown?

I'm going through some old code and found the following: public class MyClass implements Cloneable { public Object clone() { Object o = null; try { o = super.clone(); } catch (CloneNotSupportedException ex) { } return o; } } I've read the javadocs on Object.clone(), and I'm tr...

In Eclipse (Java), how do I determine where an import is actually coming from?

Say you're working on a Java project in Eclipse and you're looking at a import statement like: import com.somefirm.somepackage.AClass; and the classpath for the project has a million and one .jars on it. How do you determine where the import is coming from? ...

working with one-to-many relationship in hibernate

hello good people.I'm still learning what hibernate can do and this time i'm trying something that seems not to be working. i have 2 tables users and contacts.as you can guess contacts hold the relationship by have user_id as foreign key. here are snippet of the 2 mapping files. this first is from users.hbm.xml <set name="contactsdetail...