Is it possible to reference a column other than 'id' for a JoinColumn?

Just to report. I was able to join non-PKs in Many2One (undirectional) relation, BUT my object can't be loaded the normal way. It must be loaded with DQL like:

SELECT d,u FROM DEntity d
    JOIN d.userAccount u

this way I stopped getting error: Missing value for primary key id on ....


I think Doctrine wants these to be primary keys, from the docs:

name: Column name that holds the foreign key identifier for this relation.

Another thing that jumps out at me from your code sample is category.id2 being type string, I would at least expect it to be an integer, but it may also need to be for @JoinColumn to work properly.

You may be able to get away with just @Index on category.id2 and leave it as a string though; worth a shot anyway.