JPA database delimiters

流过昼夜 提交于 2019-12-10 09:45:44

问题


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 annotated 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>

回答1:


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.



来源:https://stackoverflow.com/questions/6791882/jpa-database-delimiters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!