Author Archives: Robert Piasecki

About Robert Piasecki

Husband and father, Java software developer, Linux and open-source fan.

Immutable objects

Most of the objects in Java are mutable. It means that their state/fields can be changed after the object was created. The examples of those are: ArrayList, Calendar, StringBuilder. Immutable objects An object is immutable if its state/fields cannot be … Continue reading

Posted in Java, Software development practices | Tagged | Leave a comment

Delete directory with contents in Java

Removing empty directory in Java is as simple as calling File.delete() (standard IO) or Files.delete() (NIO) method. However, if the folder is not empty (for example contains one or more files or subdirectories), these methods will refuse to remove it. … Continue reading

Posted in Java, Maven, Uncategorized | Tagged , , , | Leave a comment

How to delete file in Java

File management (good old CRUD: create, read, update, delete) is quite common operation in software development. In this short post I would like to present 2 ways of removing files in Java. Method available in every Java version Every Java … Continue reading

Posted in Java, Uncategorized | Tagged , | Leave a comment

Mapping a map of simple types in JPA using @ElementCollection

In the previous post I have shown how to easily map a collection (e.g. Set or List) of simple types in JPA. Today I would like to present how we achieve something similar for Java maps like HashMap or TreeMap. … Continue reading

Posted in Hibernate, JPA | Tagged , | Leave a comment

Mapping collection of simple type in JPA using @ElementCollection

JPA framework provides good support for mapping collections of value types. The value types can be either simple types like Integer or String, or custom embeddable types. In this short post I would like to present two most popular mappings … Continue reading

Posted in Database, JPA | Tagged , , | Leave a comment

Importing WSDL with Java and Maven

SOAP web services are often used in commercial software. If we plan to use existing SOAP web service, we should receive a WSDL file which defines the contract between the web service and its clients. This contract defines at least: … Continue reading

Posted in Java, Java EE, Maven, Web-Services, XML | Tagged , , , , | 1 Comment

Objects utility class in Java

Today I would like to quickly mention java.util.Objects class. The JavaDoc documentation for this class says: This class consists of static utility methods for operating on objects. These utilities include null-safe or null-tolerant methods for computing the hash code of … Continue reading

Posted in Java | Tagged | Leave a comment