Derby上のJPAがBLOBサイズをデフォルトで64KBに設定する問題が発生しました。 columnDefinition = "BLOB(128M)"を設定することでこれを解決できます。しかし、これは、MS SQLのような別のRDBMSに対する統合テスト中に失敗します。私がしたいのは、orm.xmlを使用してcolumnDefinitionを設定することです。しかし、私の試みは役に立たず、これを働かせることができません。私が期待するように、またはに設定された値が注釈を無効にしているようには見えません。orm.xmlは注釈を無効にしません
私はJPA 1.0、Toplink Essentials 2.1.60を使用しています。
私は、次のエンティティのような注釈を付けています
package foo;
@Entity
@Table(name = "Attachment")
public class Attachment implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Version
@Column(name = "VERSION")
private Integer version;
@Column(name = "FILE_NAME", nullable = false)
private String name;
@Lob
@Basic
@Column(name = "ATTACHED_FILE", nullable = false)
private byte[] file;
}
のpersistence.xml(META-INFにあります)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="LAS-OOC" transaction-type="RESOURCE_LOCAL">
<provider>${jpa.provider}</provider>
<!-- this isn't required, i know, but I'm trying everything I can think of -->
<mapping-file>META-INF/orm.xml</mapping-file>
<class>foo.Attachment</class>
<properties>
...
</properties>
</persistence-unit>
</persistence>
orm.xml
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings 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
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0">
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>TEST</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
<entity class="foo.Attachment" access="FIELD" >
<attributes>
<basic name="file">
<!--
I'm using maven profiles to set the 'jpa.blob.definition' property. I even tried changing the column name.
-->
<column nullable="true" name="ATTACHED_FILE_MODIFIED" column-definition="${jpa.blob.definition}" />
</basic>
</attributes>
</entity>
</entity-mappings>
それは面白いですorm.xmlのエンティティクラスまたは基本的な名前属性を変更した場合、無効である/見つからないと告げることに注意してください。それはそれを読んでいると私に伝えますが、ファイルで指定された注釈を上書きしていません。デフォルトのスキーマさえ使用されていません。
orm.xmlでアノテーションをオーバーライドするとは限りませんか?これは単純ではありませんか?
私たちは積極的に人々にそれを行うように勧めているので、DataNucleus JPAを使ってそのような情報を無効にすることができます。 TopLinkのバグでしょうか? – DataNucleus