Skip to content

Category Archives: Spring

Generic Entity Converter for JSF / Spring / JPA

If you’ve come across Seam’s <s:convertEntity> and wondered why isn’t one there for JSF, here you go: Before using this, you should’ve designed your domain model to extend a Base Class (do it, it’s a good practice). In my case, I have BaseIdentityEntity which has an @Id, @Version properties import java.io.Serializable; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; [...]

Mapping a clob type in hibernate and oracle 9i/10g

The easiest way to map a CLOB type of Oracle to a pojo in Hibernate, is to setup a user defined type in Hibernate, which converts Oracle’s ClobType to a String and vice versa. So you’re pojo’s property is going to be a “String” type. There are only two steps to setting this up: 1) [...]

Headless Javascript Unit Testing

I gave a presentation at work a couple of months ago covering JavaScript scoping considerations for a team of Java developers new to JavaScript. During the presentation, I used Rhino to run the examples. I have seen other projects that use Rhino for unit testing, but they seemed a little heavy weight for what I [...]

Spring Integration Presentation with Mark Fisher

I had a chance to attend Mark Fisher‘s presentations a couple of times before at NEJUG. This time around, it was a local Java Meetup group in Cambridge. He’s a very humble and knowledgeable guy about a lot of things, from Spring to Hibernate to Seam, to Scala & MDA! With a brief introduction on [...]

Generating Excel Formulas with Spring MVC and POI

I figured I’d lay this out there. It’s not awesome code, just quick and dirty. But it works. @Override protected void buildExcelDocument(Map model, HSSFWorkbook workbook, HttpServletRequest req, HttpServletResponse resp) throws Exception { //CREATE THE SHEET String periodDate = (String)model.get(PAYROLL_PERIOD_KEY); HSSFSheet sheet = workbook.createSheet(periodDate); sheet.setDefaultColumnWidth((short) 12); //GETCELL: getCell(SHEET, ROW, COLUMN); short currentRow = 0; //WRITE ROW [...]

Limitations of AbstractTransactionalDataSourceSpringContextTests

This has apparently gotten a fair amount of attention over the last year or so, but I never encountered it until today- call me lucky. Here’s the situation, you’re using Spring MVC and you have a controller that extends another controller (A->B). Your unit test extends AbstractTransactionalDataSourceSpringContextTests, and makes use of autowiring. You write your [...]

HSQLDB Integration Into Spring Security

Adding a database back end to Spring Security seems deceptively simple. And to be fair, there are several ways to do it. The way I had in mind looked like a shortcut. In my application there is basically one table for all users. It contains the values I need for username, password, role, and the [...]

Spring Security -> Replacing Acegi

Astute readers of my last Acegi article will note that Acegi has been assimilated into the Spring project, and is now called Spring Security. This next example is how I was able to get Spring Security running on my webapp. I decided early on that I did not want to mess up the other developers [...]

Configuring Applications with Spring

Carbon Five Community has a really nice article on different ways of implementing/overriding properties files in Spring. In a real-world application, we not only need to collect settings, but also override them in different environments. Many of our applications are deployed in 4 or more environments (developer machine, build server, staging server, and production), each [...]

Acegi 1.0.8 Example (Life Without the SecurityEnforcementFilter)

Note; This was my first day of adding Acegi to an existing webapp. You can find a lot of Acegi security framework examples on the web these days. Unfortunately, nearly all of the examples use Acegi use the pre 1.0 version, which is before someone removed the SecurityEnforcementFilter.. The official description of this event follows: [...]