Skip to main content

Posts

How could I be so stupid using hibernate criteria with timestamp?

I needed to make a query to find all records valid today for columns with effectiveFrom and effectiveTo range I spent a couple of hours trying to understand why             criteria.add(Restrictions.ge("effectiveFrom",currentDate.getTime()));             criteria.add(Restrictions.le("effectiveTo",currentDate.getTime())); was giving no results. After many trials and attempts with other criteria tricks, I remembered that hibernate is not comparting if  currentDate.getTime is greater than effectiveFrom, but if effectiveFrom is greater than currentDate.getTime So correct sintax for it was the exact opposite             criteria.add(Restrictions.le("effectiveFrom",currentDate.getTime()));             criteria.add(Restrictions.ge("effectiveTo",currentDate.getTime())); This one worked as it should 

Java ALWAYS passes by value (and it is ALWAYS an interesting discussion)

Always good as a refresher. So, when calling a method For primitive arguments ( int ,  long , etc.), the pass by value is  the actual value  of the primitive (for example, 3). For objects, the pass by value is the value of  the reference to the object . http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value

How I ran Gradle with cntlm

I was behind a corporate firewall and had to run gradlew (gradle) from Cygwin. The system was running a cntlm authentication proxy. I ran the following command export http_proxy=http://127.0.0.1:3128/ export https_proxy=$http_proxy Then I ran ./gradlew -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3128 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 I hope it helps 

UNION makes ALL the strength

Following the advice from a very expert consultant, I changed my views from an UNION between two select from the same table to UNION ALL and the performance improvements were simply amazing. Before doing so, I had verified that the query were returning different results with the INTERSECT command before doing so. The difference is that UNION verifies that records are unique, while UNION ALL doesn't. The performance gain is very remarkable 

Hibernate Stored Procedure with first parameter not "OUT"

I spent some days trying to call a Stored Procedure through Hibernate. I used CreateSQLQuery  and I made my own custom transformer, but I could not get it work. I keep geeting Wrong Type and Parameter of procedure exception. My procedure was like the following     procedure GET_BY_EMPLOYEE (         P_EMPLOYEE_ID   in       EMPLOYEE_ID%TYPE       , P_DATE_FROM  in       date       , P_DATE_TO    in       date       , P_REF           out      CURSORREFERENCETYPE); After days of searching, I found this http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch13.html#sp_query For Oracle the following rules apply: A function must return a result set. The first parameter of a procedure must be an  OUT  that returns a result set. This is done by using a  SYS_REFCURSOR ...

Eclipse: spaces instead of tabs

This really bugged me for a while, code formatting was quite miserable outside of the editor. You just have to go into --> preferences --> editor --> Text Editors

Building bitcoin/litecoin on mac os x missing EC.h

For my own fun, I was playing around with bitcoin, to check how the parameters of the cryptocurrencies can be modified. After recent upgrades to my OS, I could not build any longer the bitcoind. Seems like something changed on that side. Now this command ./configure --with-gui=qt5 --enable-debug Was sistematically producing  configure: error: OpenSSL ec header missing EC is the file for elliptic curve cryptography. I had brew correctly configured, and the header files were all correctly present. After some time spent inspecting the issue, on github I was able to find the solution for this problem. I simply add to export the following export LDFLAGS=-L/usr/local/opt/openssl/lib export CPPFLAGS=-I/usr/local/opt/openssl/include There is aksi pull request on bitcoin for that, I hope I could save you some time https://github.com/bitcoin/bitcoin/pull/6885/files?diff=split&unchanged=expanded

Swift language

Just for fun, I am giving a look to the new "Swift" programming language from Apple. I have to say it looks pretty cool. Type inference, tuple, and optionals can really save a lot of time during development. I am really eager to try it more extensively. 

SVN: E175002: Getting crazy with Maven Release Plugin (solved)

I was trying to use Maven Release Plugin on my cygwin to upload a versioned library into my archiva repository. I was keep and keep getting this exception. svn: E175002: Processing OPTIONS request response failed: Premature end of file. (/) svn: E175002: OPTIONS request failed on '/'         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)         then I noticed that in my pom files I had the following scm connection ...

Beethoven a Latina

Immaginate se Ludwig Beethoven, anzichè nascere a Bonn negli anni 70 del settecento, per uno scherzo del destino fosse nato un po' piu' giu', mettiamo da qualche parte in Lazio, e appena qualche anno dopo, mettiamo un paio di secoli. Beethoven si siede, ha una grandissima idea, comporrà la nona sinfonia. Si siede sul tavolo è ispiratissimo, sente proprio la melodia scorrergli nelle vene e riempirgli il cuore...driin driin, un poke su facebook della sua amica, quella stronza profumiera di Elisa, che sono anni che gli ronza attorno e non gliel'ha data mai. "Ke fai?" "Elisa, sto componendo la nona sinfonia". "Xke', le altre otto che hanno fatto? Ci facciamo un giro all'iper?". "Non posso, sto lavorando". "E dai vieni che ti faccio conoscere uno che mi piace". Maledetta...giocare cosi' con i suoi sentimenti... attacca. Ritorna a scrivere, la melodia torna potente nel cuore, una nota, poi l'altra, poi...

Extracting a single field from a very long json file

Trivial task, but still can save some time to somebody, so I am gladly sharing. A friend of a mine has an huge json file, and she had to extract all unique value for a field called "title".  The file was too big to be processed from a notepad or an excel. With those comands, I was able to obtain a clean, unique and sorted list list of all the content. grep -o -E '"title":"[^"]+",' tmp.json | sort |uniq > output.txt sed -i 's/"title":"//g' output.txt sed -i 's/",//g' output.txt

A new redbook!

Time for changes, you know... but I have good news!  The redbook "Building and implementing Social Digital Experience", one I had the honor to co-author, is finally out! http://www-10.lotus.com/ldd/portalwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Redbooks%3A+Building+and+Implementing+Social+Digital+Experiences#action=openDocument&content=catcontent&ct=redbooks

Playing with Apache...

If you are playing with Apache on Windows and you keep getting E:\IBM\HTTPServer\bin>apache.exe -k start [Fri Jan 31 00:12:00 2014] [notice] Disabled use of AcceptEx() WinSock2 API (OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted.  : make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Before getting mad and reviewing all your httpd.conf line by line, try to quit Skype. Yes, by default it opens port 80 !!!

How a Global Admin knows about the communities to modify?

Moderation in Connections 4.5  is an awesome feature, but may be pretty cumbersome. If you decide to moderate everything before it get published (ex-ante), you will enforce an strict rule over you social network. If you moderate after publishing (ex-post) ,you are basically relying on good will of other users flagging content around your organization.  IBM Connections not offers you the very powerful role of Global Admin. It's a J2EE role, it is present both on Communities and Search (and other features too), but now let's focus on these two features. So, a global admin can do everything on every community: great stuff, but how he gets to know a community exists?  With the basic community ui you have access to  1) Communities you own 2) Communities you are a member of 3) Public communities And the global admin role technically is neither of three. That's why the global admin role is also on search application, where he can see everything. So g...

SECJ0118E with form authentication and spnego enabled

Our deployment keeps getting an odd SECJ0118E  exception when authenticating with Form authentication with Mozilla or Chrome browser not configured for Active Directory Domain. All instructions into WebSphere infocenter for enabling fallback to default authentication were correctly applied.  We noticed that standard WebSphere security tracing ( *=info:com.ibm.ws.security.*=all:com.ibm.websphere.security.*=all:com.ibm.websphere.wim.*=all:com.ibm.wsspi.wim.*=all:com.ibm.ws.wim.*=all)  provided into trace a lot of Kerberos exceptions.  [30/12/13 17.36.57:246 CET] 0000005e Krb5LoginModu < login() Exit javax.security.auth.login.FailedLoginException: Errore di login: com.ibm.security.krb5.KrbException, codice di stato: 68 messaggio: Nessuno at com.ibm.security.jgss.i18n.I18NException.throwFailedLoginException(I18NException.java:30) at com.ibm.security.auth.module.Krb5LoginModule.a(Krb5LoginModule.java:719) at com.ibm.security.auth.module.Krb5LoginMo...