SysHex was the nickname chosen by me more than fifteen years ago, when I started university. This blog was created under that name mainly because I was the main contributor to it. Some time has passed and basically all posts here were created and contributed in some way by me and all, my friends and colleagues over at JBay Solutions.

So, we are re-branding the blog! JBay Solutions is the name of the company we have created a bit over four years ago. We are focused on Java development, specially the JavaEE side of it. We have also started Android development over one and a half years ago. We are based in Lisbon, Portugal.

We’ll keep on doing what we do, but it just seemed to make more sense to have this place under JBay Solutions instead of my nickname. That’s about it!


JPA 2 Tutorial – Many To Many with Self

selfWe have just covered the subject of Many-To-Many relationships, which is a fun topic for the hole family! Now there are some particular cases on the Many-to-many front which are not particularly hard, but can lead to a bit of confusion. One of those particular cases is the M2M with same table.

A reader asked : “How would one create manyToMany relationship with the same entity. Entity user can have friends (user), and can be friend to other users. With note that junction table has to have some additional columns besides user keys. How can that be achieved?”  (Thanks Felix for the feedback and question!)

Read more of this post

JPA 2 Tutorial – Relationships – Many To Many

So, we have already dabbled into Relationships in JPA, in particular One-To-Many and Many-To-One. It is now time to give a look into Many-To-Many, which is very similar to One-To-Many Relationships. So at this point you should have read the previous two tutorials on JPA 2, but if for some reason you don’t know what I’m talking about, give a look at these two links, they will help quite a bit:

Read more of this post

Apache POI, translating Excel column number to letter

Recently I had to write some code to generate excel files using Apache POI. One of the files was fairly complex and used formulas in a few cells.

I found myself spending a few hours searching for a way to translate the indexed column numbers that POI uses to the column letters I needed in those formulas.

It turns out the solution is quite simple, you just have to use org.apache.poi.hssf.util.CellReference:

String columnLetter = CellReference.convertNumToColString(columnNumber);

Enabling remote JMX on Glassfish 2.1.1

The default glassfish app. server installation comes with local JMX connections enabled by default.

To enable JMX connections from remote hosts all that’s needed is to add -Djava.rmi.server.hostname=<hostname> in the JVM Options of the instance of GlassFish, where <hostname> is the external hostname of the server where glassfish is running.

Java Threading and Concurrency Introduction

Multi Threading is one of the most interesting subjects when developing applications, be them in Java or any other Language: The ability to have ones software performing multiple tasks at the same time, maybe handling multiple requests from users, parallel processing things… wicked stuff really!

On the other hand… when things go wrong with multi threading, they go wrong really fast, they go wrong all over the place, it is hard to debug (specially if threads “share” stuff) and you get the usual comment: “I just don’t get it why this is doing this”. Multi Threading is not without challenges!

In this Tutorial we’ll be going through a bit of theory regarding threads and the Java memory model, but I’ll try to make it as interesting as I can with examples and demonstration of concepts. We’ll see how stuff can go wrong, how to avoid those situations, and we’ll play with threads just to see them working! A more advanced tutorial will follow(at some point) in which I’ll discuss more advanced parts of Threads and Concurrency.

Read more of this post

JPA 2 Tutorial – Relationships – One To Many

Following from the previous tutorial we now dive into move interesting and complex parts of JPA 2: Relationships! In this tutorial we’ll be focusing on One-to-Many relationships (mainly Bidirectional), looking into their particularities (specially related to the Cascading of operations), we’ll create a JUnit Test class for testing the Relationship, look at what actual SQL queries that are performed, learn by example and also some more interesting theory that is related to all of this. Read more of this post