JPA database delimiters
I have a two entity classes called User and Group, both reserved words that need to be delimited in order for the database to accept them as tables. Annotating the entities with:
@Table(name = "\"USER\"")
does the trick, but I read that EclipseLink allows you to specify a global that automatically delimits names. According to http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg03434.html, you need to include the following in orm.xml:
<persistence-unit-metadata>
<persistence-unit-defaults>
<delimited-identifiers/>
</persistence-unit-defaults>
</persistence-unit-metadata>
I have annot开发者_如何学JAVAated my classes however, and do not have an orm.xml, only a persistence.xml, where, according to the same source, I cannot include that property. Is there anywhere else I can specify:
eclipselink.database.delimiters = true
when the actual entity manager is being injected through @PersistenceContext?
Thanks!
Update:
Thanks James. I ended up with the following orm.xml
and it does the trick perfectly!
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">
<persistence-unit-metadata>
<persistence-unit-defaults>
<delimited-identifiers/>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
You should be able to add an orm.xml, it only needs to have this setting, you can still define all of your mappings in annotations.
精彩评论