Sunday, December 21, 2014

The Value of Annotation @Temporal for Date Related Columns

The annotation @Temporal in official javadoc is described like below: This annotation must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar. So when the field variable is a java.util.Date or java.util.Calendar, it MUST be annotated by @Temporal. There...

Thursday, December 18, 2014

How to configure primary key's generator in JPA entity for oracle

In JPA there are 4 strategies to automatically generate value for a primary key column: Auto Identity Sequence Table To some extent, there are only 3 strategies, the last 3 ones. Because the first 'Auto' just let the JPA implementation to choose which one of the rest 3 strategies it will use. For example working with Oracle + EclipseLink 2.5.0,  the "Auto" will result in the strategy "Table"...

Tuesday, December 9, 2014

How to create Java classes from existing tables in database for JPA

If JPA is your persistence layer in your project and you have tables already defined in database. You can use JPA tools in Eclipse to automatically create corresponding Java Entity classes from those tables in database. In this article, Java JPA entities will be created from an oracle database on LAN....

Monday, December 8, 2014

How to add oracle DB connection in Eclipse

Have a DB connection in Eclipse will be very helpful if you need use persistence frameworks like Hibernate or JPA.  It's normally a prerequisite for other functions, for example let eclipse create java entities class from database tables automatically.  Here's how to configure oracle connection...

Tuesday, December 2, 2014

How to disable c3p0 from writing log to screen (stderr)

Even if you have slf4j and logback configured in your project, the c3p0 insists on writing log to system error channel like this: The Eclipse console show log from c3p0 in red, because the texts are written to stderr.  The way to dismiss those red part from c3p0 is add two lines at the beginning...

Monday, December 1, 2014

How to inject a logger variable by using annotation in Spring

In development, we need logger almost everywhere. you can inject a bean with annotation like inject other beans package com.shengwangi.demo; @Component public class MyClass { @Loggable Logger logger; public void myMethod() { // do some thing logger.info("use the logger as usual"); } } As you can see, annotation @Loggable is used to inject the logger. @Loggable is an annotation that...

Tuesday, November 11, 2014

How to simply print object content to String in Java

During development, you may frequently want to dump a Java object's all contents into a String for debug and  log.  You object has  fields  of primitive data type as well as List and Set. In java, dump a object to a more meaningful String will need you to override the toString() method. It's a bad practice to assemble the output string by hand, which is tedious and difficult to...

Tuesday, October 14, 2014

Quick Tutorial on ActiveMQ Web Console In 5 minutes

There are some basic operations when developing with ActiveMQ: Browse all Queue  (Queues List) Browse  all messages in a Queue (Message List) Check detailed information of any message Create a Message manually from web Delete a specified message in a Queue Delete all messages of a Queue...

Spring JMS with ActiveMQ - hello world example - receive message using message listener adapter

This tutorial will demo how to receive message by using Spring JMS and ActiveMQ. This tutorial uses Spring JMS's MessageListenerAdapter. Compare to receiving message using MessageListener interface, there are 2 advantages you can get: Use any POJO class as real message listener, no need to implements...

Friday, October 10, 2014

Spring JMS with ActiveMQ - hello world example - receive message using direct message listener

This tutorial will demo how to receive message by using Spring JMS and ActiveMQ. This tutorial uses class directly implements Spring JMS's MessageListener or SessionAwareMessageListener interface. There are other ways to  receive message from ActiveMQ broker using Spring JMS, examples are provided...

Tuesday, October 7, 2014

Spring JMS with ActiveMQ – hello world example – send message

Before we start, let make some concepts clear .  What’s the role for each part of the JMS/Spring JMS/ActiveMQ combination.What’s JMS ? In short, JMS is a set of APIs defined in JSR. In practical you can think it’s a set of Java Interfaces. JMS is part of the JEE standard coming with JDK in package...

Monday, September 15, 2014

Play with Java byte array

Java byte variable is mostly used when you do some low level programming. Let's go though some FAQ you will meet when using Java byte array. How to initial a byte array with values? How to convert a byte array to String? How to convert a String to byte array? Here are some ASCII characters and their values that used in the following demo lines: Character Value in hex Value in ...
Powered by Blogger.

About The Author

My Photo
Has been a senior software developer, project manager for 10+ years. Dedicate himself to Alcatel-Lucent and China Telecom for delivering software solutions.