| Hi Andrea Boriero, thanks for your quick reply. After adjusting my code with
@Table(name ="Entity", schema = "bug")
, the schemas and entities were properly created for their respective schemas. I expected the schema "bug" and "bug_other" to be created from the @Entity annotations, which didn't happen. I can see why, though. After your comment I've been skimming through the JPA 2.1 specification and was trying to find the specifics that result in your conclusion. First I've found that section 11.1.49 Table Annotation says that if a table annotation is missing, it should be assumed that all entries are set to the default values. Then section 4.3.1 Naming says that
Entities are designated in query strings by their entity names. The entity name is defined by the name element of the Entity annotation (or the entity-name XML descriptor element), and defaults to the unqualified name of the entity class.
So I can see that the entity name is used. Interestingly this conflicts with 2.13 Naming of Database Objects, where it says
This specification requires the following with regard to the interpretation of the names referencing database objects. These names include the names of tables, columns, and other database elements. Such names also include names that result from defaulting (e.g., a table name that is defaulted from an entity name or a column name that is defaulted from a field or property name).
As of yet I have not been able to find something along the lines of "Whenever an entity is mapped to their respective Relational Model, the respective table name is used". I have also not yet found where exactly the specification says how the schema is generated from the @Table annotation, but I can see why it should be like that. At any rate, I will adjust my code accordingly and close this issue. Thanks again! |