Postgres array column type, selecting where X in column

26 views
Skip to first unread message

Brandon Perry

unread,
Jan 2, 2017, 2:22:01 PM1/2/17
to fluent-n...@googlegroups.com
I have a schema with uuid[] columns and I am using a custom driver in order to persist a Guid[] to the uuid[] column. This works well.

If I have a Guid, how can I use the hibernate criteria to select all rows from column where column contains X? I expected a Restrictions.Contains, but only see Restrictions.In, which doesn’t appear to do what I want.

Example Table

CREATE TABLE foo (
ID UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
SearchTerm text,
Categories uuid[],
Timestamp timestamp
);


If I wanted to create a criteria search for all search queries who Categories contained X, is this something I need to write my own code in the driver to do? I may need to create a separate table to union against otherwise.

Brandon Perry

unread,
Jan 2, 2017, 2:46:12 PM1/2/17
to fluent-n...@googlegroups.com
So, it looks like

criteria.Add(Restrictions.Eq("ANY(Categories)", cat));

will probably do what I want.

Reply all
Reply to author
Forward
0 new messages