Java + Javassist = Simple bytecode manipulation Few days ago, I was trying to look for inspiration on internet about that how to generate java class during runtime and I was surprised by that I was not able to find any example. So here we go! It is really simple. You can get this code […]
java

Custom Java annotations – Quick example of easy and powerful Java function
Development of custom Java annotations is really quick and usage of annotations is really awesome and it provides very easy way how to offer customization. In this short post we are going to create a simple application with custom annotation for FIELD type. I’d like to show you only basic concept and I believe that […]

How to disable weak cipher suites in Java
If you want to set up used cipher suites in your Java application, you can do it by property jdk.tls.disabledAlgorithms for TLS ciphers and jdk.certpath.disabledAlgorithms for SSL certificates, in security policy file java.security. This file is located in {APP_HOME}/jre/lib/security folder. If you want to set which TLS will be used, you can do it in the same […]

Hibernate – CASE WHEN in HQL – ParameterNode cannot be cast to SelectExpression
If you want to use SQL USE … WHEN … ELSE expression in HQL (Hibernate Query Language), you may faced to this: java.lang.ClassCastException: org.hibernate.hql.internal.ast.tree.ParameterNode cannot be cast to org.hibernate.hql.internal.ast.tree.SelectExpression This exception is raised during parsing SQL to HQL. If you will check method getFirstThenNode() from class CaseNode.java in package org.hibernate.hql.internal.ast.tree, you are able to see casting to SelectExpression. And there is […]

Enum – Create groups for values
If you need to create groups for your Enum class, there are few options which you can choose. Here is examples of two ways. Inner Enum class public class EnumGroups { public enum Fields{ USER_NAME(Group.USER_BASIC), USER_SURNAME(Group.USER_BASIC), USER_EMAIL(Group.USER_BASIC), USER_PHONE(Group.USER_BASIC), USER_STREET(Group.USER_ADDRESS), USER_ZIP(Group.USER_ADDRESS), USER_COUNTRY(Group.USER_ADDRESS), USER_NEWS(Group.USER_SETTINGS), USER_PRODUCT(Group.USER_SETTINGS); Fields(Group group) { this.group = group; } private final Group group; public […]

Quick tutorial to getting messages from resource bundles
If you need to get messages dependent on locale setting and you are using Spring Framework, you are able to use ResourceBundleMessageSource and localize them very quickly. At first, we will create a Resource Bundle files named with lang postfix to Resource folder: Next step will be that to say our application about that we want […]