I'm getting a large stack trace which at its root is caused by: java.sql.SQLSyntaxErrorException: Table/View 'U' does not exist.
Followed by an exception for everything that requires the entity: java.sql.SQLTransactionRollbackException: Constraint 'PSSVSERSRDTABASEID' is invalid: referenced table U does not exist.
I looked at this question and answer about a similar issue but it doesn't seem to address my particular problem. The reason being is when I open Database Development
mode in Eclipse, I can see every other entity being mapped to a table, yet, not the entity User('U').
The User entity:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "disc", discriminatorType = DiscriminatorType.STRING)
@Table(name = "U")
@NamedQuery(name = "FIND_WITH_USER_ID", query="SELECT DISTINCT u FROM User u WHERE u.userId = :userId")
public class User implements Serializable{
private static final long serialVersionUID = 2468889149889625824L;
@Id @GeneratedValue
protected long databaseId;
//getters/setters/etc
}
User does have a subclass (which shows up in the table schema):
@Entity
public class Customer extends User{
private static final long serialVersionUID = -5239293307816318553L;
public Customer(){
super();
}
//getters/setters/etc
}
In my persistence.xml file, I do specify for the tables to be created if they don't already exist:
<properties>
<property name="javax.persistence.jdbc.driver" value="C:\Program Files\GlassFish\glassfish-4.1\glassfish4\javadb\lib\derby.jar"></property>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/AppDB;create=true"></property>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
As stated, other tables are shown in the database schema (and pings to the database succeed). The problem seems to form around the User entity. I thought it might have had something to do with reserved keyword name clashes, so I changed the name of the table a few times (there seems to be a problem with Eclipse/Glassfish once I encounter this exception, even if I make changes, such as the name, and relaunch the app it doesn't update; out of scope of question I believe).
Why isn't a table being created for entity User? What am I missing? Why are the other tables being created still?