Figured it out and answering for posterity:
As @dozortsev-anton mentioned, we need another xml file in src/test/resources
- but instead of another persistence.xml
with different persistence units, we need an actual orm.xml
to map the entity:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
version="2.0">
<entity class="my.wonderful.class">
<table name="TABLE_NAME" />
</entity>
</entity-mappings>
Note that just writing the <entity>
node (without the table
element inside) is sufficient for IntelliJ IDEA to recognize the class as an entity and start auto-completing queries where this class is used. However, the column names will not be recognized:
(upon hovering you'll get the "Cannot resolve column..." error).
The table
element will fix this - by mapping the entity to the table (the same table as you have in the @Table
annotation) all errors will be gone.