java

Ibatis : Is there a way of adding a rowhandler in an Ibatis resultmap subselect within the sqlmap xml?

I have a two ibatis sql maps that are linked together via a sub select like the simplified example below: <resultMap id="order" class="Order"> <collection property="orderLines" ofType="OrderLine" resultMap=”orderLine”/> </resultMap> I have an order object that contains a collection of line objects that are returned by a join and an ...

If it is possible to auto-format code before and after a source control commit, checkout, diff, etc. does a company really need a standard code style?

If it is possible to auto-format code before and after a source control commit, checkout, diff, etc. does a company really need a standard code style? It feels like standard coding style debates that have been raging since programming began like "put the bracket on the following line" or "properly indent your (" are no longer essential....

Object-Oriented Execution

Consider the following source snippets: Snippet #1 StoredProcedure sp = new StoredProcedure( "PROC_NAME", getConnection() ); sp.putParameter( "ID", getId() ); sp.execute(); Snippet #2 StoredProcedure sp = new StoredProcedure( "PROC_NAME" ); sp.setConnection( getConnection() ); sp.putParameter( "ID", getId() ); sp.execu...

is the Java HashMap keySet() iteration order consistent?

I understand that the Set returned from a Map's keySet() method does not guarantee any particular order. My question is, does it guarantee the same order over multiple iterations. For example Map<K,V> map = getMap(); for( K k : map.keySet() ) { } ... for( K k : map.keySet() ) { } In the above code, assuming that the map is not mo...

How can I create a java list using the member variables of an existing list, without using a for loop?

I have a java list List<myclass> myList = myClass.selectFromDB("where clause"); //myClass.selectFromDB returns a list of objects from DB But I want a different list, specifically. List<Integer> goodList = new ArrayList<Integer>(); for(int i = 0;i++; i<= myList.size()) { goodList[i] = myList[i].getGoodInteger(); } Yes, I could...

Hibernate. big Results and Pagination

Hi there, atm I'm fetchin a small amount of data (round a bout 100 records) as list and let displaytag render a table for this data. Now I'm facing a problem: I'm in need to show more results at once. If the query results in a size of > 5000 objects everything slows extremly down. I was wondering if there are any best-practices to reci...

Removing MyFaces Orchestra's "conversationContext" GET parameter from static resources (css, images)

MyFaces Orchestra adds a ?conversationContext=x to each resource on a page. Since I'm not using the conversation scope for the public part of my project (only for the admin part), I'd like to get rid of that parameter for two reasons: it breaks the browser caching of static resources it's ugly :) I'm now going to take a look at Orche...

RandomAccessSubList not serialized

I am trying to get a sublist of a List but I want the sublist to be serialized. I found out that when we get sublist from an ArrayList the sublist is not serialized. To overcome this, this is what I am doing: ArrayList serializedSublist = new ArrayList(); //getQuestions() returns RandomAccessSubList getQuestions().addAll(serializedSu...

database sort vs. programmatic java sort

hi, I want to get data from the database(MySQL) by JPA, I wand it sorted by some column value, So, what is the best practice, to: Retrieve the data from the database as list of objects (JPA), then sort it programmatically using some java APIs. OR Let the database sort it by using a sorting select query. ?? thanx in advance ...

Java: System.out.println and System.err.println out of order

My System.out.println() and System.err.println() calls aren't being printed to the console in the order I make them. public static void main(String[] args) { for (int i = 0; i < 5; i++) { System.out.println("out"); System.err.println("err"); } } This produces: out out out out out err err err err err Instead of alternating out...

What's up with Java's "%n" in printf?

I'm reading Effective Java and it uses %n for the newline character everywhere. I have used \n rather successfully for newline in Java programs. Which is the 'correct' one? What's wrong with '\n' ? Why did Java change this C convention? ...

JSF multiple backing beans on one page

I have done some reading and playing and I still have some questions I was hoping someone might answer: So, can I use two or more backing beans in a single JSF page? <h:intputText value="#{myFirstBean.firstProperty}" /> <h:intputText value="#{mySecondBean.secondProperty}" /> If I can, why should I not do it? (I assume I should not, b...

Learn Java from Python background

I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. Coming from a dynamic l...

Success stories of creating Thumbnail images on demand using java

I have a bunch of images on a server. When client requests url for image, the client can specify to either receive the full image or get a thumbnail of the image. So, I'm looking to implement a servlet type solution that processes request, and generates thumbnail on demand if needed. It needs to support jpg, gif, tif, png. It looks like...

Accessing FacesContext in Util jar from multiple portlets

We have several JSF portlets running in a websphere portal environment. A developer wants to create a Utility jar which would live in the shared library, so all portlets could access it. In this jar he wants a faces utility class which would have a static method; this method would access the current FacesContext instance and return that ...

Best Practices for implementing a Lucene Search in Java

Each document in my Lucene index is kind of similar to a post in stackoverflow and I am trying to search through the index (which contains millions of documents). Each user should only be able to search through the user's company posts only. I have no control over how the data is indexed and I only need to implement a simple search (tha...

Focus behavior in Applet-Javascript interaction

I have a web page with an applet that opens a popup window and also makes Javascript calls. When that Javascript call results in a focus() call on an HTML input, that causes the browser window to push itself in front of the applet window. But only on certain browsers, namely MSIE. On Firefox the applet window remains on top. How can I ke...

Read User Input from Tomcat startup

I have a Tomcat application that requires multiple passwords on startup. My current configuration uses a Java Properties object to load in the passwords from a password.conf file. There's now a requirement that no passwords are allowed in 'the clear' on the system. I had suggested encrypting the password file, but this isn't an option. ...

Spring Form: Submitting extra parameter on submit buttons

Hi, I am working on a form with a bunch of selection criteria that will generate a report when the form is submitted. I also have a number of different reports that can be generated form this same criteria, and want the type of report to be selectable by using a tab system where each tab clicked on submits the form and generates the cor...

Problems with Web Service Data Source in Crystal Reports 2008

I'm trying to hook up my SOAP webservice to be used as a crystal reports data service and I'm running into some problems. I follow the wizard and after I enter my WSDL URL and my credentials, I go on to the final page. On this page, the drop down boxes are empty. I manually enter the service name, port and method, and then hit finish ...