java

how to simple add an object to a collection in hibernate from client

Hello, I'm trying to add an object to a collection in my client view and to save it on server with hibernate/jpa mechanism. Here is the problem: Take a Group object which can contains Account objects. On my client view (gwt), I create a new group (so the id is null) and I add to this group some accounts (where ids exist). BUT these ac...

Thread.isInterrupted doesn't work, Thread.interrupted does

The following program demonstrates the problem (latest JVM & whatnot): public static void main(String[] args) throws InterruptedException { // if this is true, both interrupted and isInterrupted work final boolean withPrint = false; // decide whether to use isInterrupted or interrupted. // if this is true, the program n...

Comparing StringBuffer content with equals

StringBuffer sb1 = new StringBuffer("Java"); StringBuffer sb2 = new StringBuffer("Java"); System.out.println(sb1 == sb2); System.out.println(sb1.equals(sb2)); Here both are returning false. How is it possible? ...

How to create expressions of type Class<List<?>>

Take the following: public Class<List<String>> getObjectType() { // what can I return here? } What class literal expression can I return from this method which will satisfy the generics and compile? List.class won't compile, and neither will List.<String>class. If you're wondering "why", I'm writing an implementation of Spring's ...

agent aspectjweaver causes ClassCircularityError

I use aspects to add some targeted tracing for performance analysis. Everything used to work fine till this recent drop. Now, I get a ClassCircularityError at start-up. Note that this happens even without having any aspects in the classpath. I am using version 1.6.6. The stacktrace is partially as follows. Is there any other information...

What makes the following code print false?

public class Guess { public static void main(String[] args){ <sometype> x = <somevalue>; System.out.println(x == x); } } i have to change sometype and somevalue so that it returns false? is it possible? ...

Is there a difference between these two initialisation modes?

Let's say I have this: public class Whatever { private ArrayList<String> myList = new ArrayList<String>(); // more code goes here } or let's say I have this: public class Whatever { private ArrayList<String> myList = null; public Whatever() { myList = new ArrayList<String>(); } } What's the difference between t...

Operator Overloading Plugin for Java

I have seen some nice Java compiler hacks wherein you can replace assertions by throw-exception statements, you can have auto-generated properties for fields and so on... I was just wondering... Is it possible to hack Java compiler so that it supports Operator Overloading? EDIT : It's not that I am missing operator overloading in Jav...

Java GUI Toolbar

I am developing a Java Desktop Application. In that I want some toolbars at the top of the JFrame (as in usual GUI appllications). I want to allow user to add/remove toolbars dynamically by clicking on some buttons. How can I implement this (through any Layouts or some other way) so that when a user add/removes a toolbar, the rest of th...

Preserve images in Excel headers using Apache POI

I am trying to generate Excel reports using Apache POI 3.6 (latest). Since POI has limited support for header and footer generation (text only), I decided to start from a blank excel file with the header already prepared and fill the Excel cells using POI (cf. question 714172). Unfortunately, when opening the workbook with POI and writ...

Call Detail Record

Hi all, I am going to parse the cisco voip CDR using Java , please anybody knows the cisco viop cdr file format explain in detail, give the sample CDR file . if anybody have the CDR parser program please send me Regards, Barani ...

DataSource creation in JBOSS

How the datasource object is created in JBOSS ? ...

is there any concept called "Constant Folding" in java?

is there any concept called "Constant Folding" in java? if yes what is it? ...

Find objects in a list where some attributes have equal values

Given a list of objects (all of the same type), how can I make sure that it contains only one element for each value of a certain attribute, even though equals() may return false for such elements due to more attributes being checked? In code: private void example() { List<SomeType> listWithDuplicates = new ArrayList<SomeType>(); ...

Datasource creation in JBOSS for DB2

How JBOSS uses db2-ds.xml file to create datasource object for DB2? ...

get resource is null

I have an @Test method with invocationCount=3. Each time this method is run, there is a call for preparing some doc into another method. All it's working GREAT when the @Test is run for the 1st time. The doc is succesfully found and loaded: final DocumentRegistryResource documentRegistryResource = RestClientFactory.getInstance()...

What is the difference between the Java operators >> and >>>?

What is the difference between the operator >> and >>>? ...

Can anyone provide a basic example of O-notation in Java?

i am trying to find limitations of o notations, i was wondering if there was a simple example that demonstrates an enahncement to a task, where version 1 is the same o notation as version 2, yet version 2 works more efficiently after the enhancement thanks ...

Different implementations of ArrayList

We're getting this error java.lang.NullPointerException at java.util.ArrayList.<init>(Unknown Source) at de.mystuff.ExtendedArrayList.<init>(ExtendedArrayList.java:38) where ExtendedArrayList:38 is new ArrayList(new ArrayCollection<E>(data)); In short: the ArrayList constructor sometimes seems to choke on our home grown Col...

Can someone explain me what is the difference between Strong, Soft, Weak and Phantom references and the usage of it?

I have been trying to understand the difference between different references but the theory does not provoke any ideas for me to visualize the same. Could anyone please explain in brief the different references? An example for each would do better. ...