Try using SIMILAR TO
with a reqular expression A\d+(-B\d+(-C\d+(-D\d+)?)?)?
@NamedNativeQueries({
@NamedNativeQuery(
name = "finDesiredData",
query = "select * from mytable t where t.entry SIMILAR TO :ent",
resultClass = MyTable.class
)
})
I would personally use java StringBuffer
to concatenate letters into a correct regexp.