Hibernate have had an annoying bug where SQLServer columns mapped as char(n) where n > 1 are returned as a char instead of String.
varchar(n) columns are fine.
The hibernate bug is https://hibernate.onjira.com/browse/HHH-2304
It is fixed in 3.6.8 however 3.6.10 is already out so I have just downloaded & tried that.
excellent it works.
Hibernate4 is also out. I have not tried that yet but no doubt will be soon.
Friday, 10 February 2012
Wednesday, 4 January 2012
Multiple search windows in eclipse
This is a really simple but cute little feature.
If you pin one search window using the pin icon at the right hand end of buttons then the next time you do a search eclipse will open up a new Search window.
There is also a search history that you can look through just to the left of the pin icon.
If you pin one search window using the pin icon at the right hand end of buttons then the next time you do a search eclipse will open up a new Search window.
There is also a search history that you can look through just to the left of the pin icon.
Labels:
eclipse
Friday, 23 September 2011
finding the correct spring jar for a known class
With Spring 3 you now have to get all the individual jars that you need for an application.
One solution is obviously to download the lot.
But what if you just want to install what is needed.
How do you easily find which jar a class is in ?
Well I have just found this Spring Bundle Search tool.
You can enter just the class name or the class with its full package name.
One solution is obviously to download the lot.
But what if you just want to install what is needed.
How do you easily find which jar a class is in ?
Well I have just found this Spring Bundle Search tool.
You can enter just the class name or the class with its full package name.
Labels:
spring
Wednesday, 31 August 2011
windows7 Administrator mode from the command line
Type 'cmd' in the Run window as normal but instead of simply hitting the return key, use Ctrl-Shift-Return
Labels:
windows7
Monday, 4 July 2011
Auditing using AOP and annotations in Spring
Lord, how I dislike the old XML configuration for AOP (among other things).
I have not given myself the opportunity to try out Spring's annotation based AOP in spring, until now and boy is it easy (with one minor gotcha).
Here are the building blocks:
1) Make your own Annotation. This is a simple way to mark all methods you want to audit.
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface ParmsAudit { ActionAuditType auditType(); }
2) ActionAuditType is an enum that will be used to identify the thing being audited.
public enum ActionAuditType { USER_LOGGED_IN("User Logged In"), USER_LOGGED_OUT("User Logged Out"); private String mDescription;private ActionAuditType(String aDescription) { mDescription = aDescription; } public String getDescription() { return mDescription; } public void setDescription(String aDescription) { mDescription = aDescription; } }
3) Create an Aspect. This is the code that is run when the method marked by the annotation is called.
Here is the minor gotcha - well for me atleast.
I had to list the full package path to the Annotation in the @Before statement.
@Aspect
public class AuditAspect {
@Before(value="execution(@uk.co.billcomer.audit.ParmsAudit * *(..)) && @annotation(parmsAudit)", argNames="parmsAudit")
public void logTheAuditActivity(JoinPoint aPoint, ParmsAudit parmsAudit) {
String userName = getUserName();
mlogger.info("Parms Auditing User Name: " + userName);
mlogger.info("auditType:" + parmsAudit.auditType().getDescription());
String arguments = getArgs(aPoint.getArgs());
if (arguments.length() > 0) {
mlogger.info("args-" + arguments);
}
}
private String getArgs(Object[] args) {
String arguments = "";
int argCount = 0;
for (Object object : args) {
if (argCount > 0) {
arguments += ", ";
}
arguments += "arg[" + ++argCount + "]=" + "[" + object + "]";
}
return arguments;
}
private String getUserName() {
try {
return SecurityContextHolder.getContext().getAuthentication().getName();
} catch (NullPointerException npe) {
return "Unknown User";
}
}
}
4) Mark the method to be audited.
@Service("parms.DummyAuditThing")
public class DummyAuditThing implements DummyAudit {
@Override
@ParmsAudit(auditType = ActionAuditType.USER_LOGGED_IN)
public void aspectAuditMethodTwoParams(String param1, Long param2) {
mlogger.info("In method to be audited param1[" + param1 + "], p2[" + param2 + "]");
}
}
5) Context configuration
This is needed to speed up the compilation process. Essentially it tells the compiler what classes will have Aspects
<aop:aspectj-autoproxy proxy-target-class="true"/> <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/> <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/> <bean id="bill.auditAspect" class="uk.co.billcomer.audit.AuditAspect" />
Labels:
annotations,
aop,
spring
Wednesday, 1 June 2011
android phone calendar not synching
The other day the calendar on my android phone stopped synching correctly to my google calendars.
It was partly way there. It new about the calendars but would not display any of the data.
I found this which did not describe my solution 100% but put me on the right track.
Go to Settings->Applications->Manage Applications->Calendar and select 'Clear data'.
This will give you a pop up box saying all the applications data willbe deleted permanently. Do not worry & select the the 'OK'.
Now go back to your calendar app and you will find all your calendars restored.
Labels:
android
Thursday, 26 May 2011
unix WC command out by 1 - wtf
I am develop on a windows PC (for my sins) but to keep me feeling secure I use cygwin (a unix shell for windows. Today this has done me in.
The application I am working has to create files and in the final line of the file it has to include the number of the lines in the file. All simple enough and it did exactly what it was supposed to do.
However when I came to check the results manually I used the unix 'wc' command and this gave me a row count 1 less than what I was expecting and what the footer said was in the file. Strange.
I edited the file with 'vim' and low & behold wc was incorrect - what is going on ?
I then edited the file with hexEdit and noticed there was no CR & LF on the last line. Adding these made wc give the correct count.
Subscribe to:
Posts (Atom)