Question: I have an object within an object and want to create a restriction using one of the fields within the inner most object. Now i figured it could be achieved by doing something like:

... .add(Restrictions.eq("myObjectTwp.myObjectThree.myObjectsID", mySearchId)).list();

However this does not seem to work. However, I get no error message and instead it almost looks like this restriction has not been taken into account.

Answer: 
You are probably looking for [CONCAT() function](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat), and your custom parts of the sentence have to be enclosed in single quotes and have the desired spaces at the beginning and at the end:

```
SELECT CONCAT (
    A.CUSTNAME,
    ' WHO IS HOLDING ',
    A.ACCNAME,
    ' ACCOUNT ',
    T.TRATYPE,
    ' THE AMOUNT ',
    T.AMT,
    ' ON ',
    T.t_DATE
    )
FROM ACCOUNTHOLDER A
INNER JOIN TRANSACTION T ON T.ACCNO = A.ACCNO
WHERE CUSTNAME = 'JAMES BOND'

```

And your JOIN wasn't right either You either use the explicit way and add INNER JOIN and ON, or you separate your tables with commas and put the condition in the WHERE clause.
You need to use proper `join` syntax. In addition to the `on` clause, you need a `join` statement. In addition, what look like string constants should be in single quotes. And, the proper way to concatenate strings in MySQL is to use the `concat()` function, not vertical bars:

```
SELECT concat(A.CUSTNAME, ' WHO IS HOLDING ', A.ACCNAME,  ' ACCOUNT ', 
              T.TRATYPE, ' THE AMOUNT ', T.AMT,  ' ON ', T.t_DATE)
FROM ACCOUNTHOLDER A join
     TRANSACTION T
     ON T.ACCNO=A.ACCNO 
WHERE CUSTNAME = 'JAMES BOND';

```