hyperjaxb を使用して JPA アノテーション付き Java クラスを生成しようとしていますが、問題が 1 つあります。どんな提案も歓迎します:-
部分的な ..Pom.xml
<!-- hyperjaxb -->
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.5.6</version>
</dependency>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.5.6</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<id>1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>${basedir}/src/main/resources/schemas/demo</schemaDirectory>
<schemaIncludes>
<schemaInclude>demo.xsd</schemaInclude>
</schemaIncludes>
<generatePackage>com.fsi.demo</generatePackage>
<strict>true</strict>
<extension>true</extension>
</configuration>
</execution>
</executions>
</plugin>
これがdemo.xsdです:-
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="demo">
<xs:complexType>
<xs:sequence>
<xs:element ref="playerID" />
<xs:element ref="G"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="playerID" type="xs:string" />
<xs:element name="G" type="xs:string" />
</xs:schema>
生成されたJavaクラスは次のとおりです
public class Demo
implements Equals, HashCode
{
@XmlElement(required = true)
protected String playerID;
@XmlElement(name = "G", required = true)
protected String g;
@XmlAttribute(name = "Hjid")
protected Long hjid;
....
...
/**
* Gets the value of the g property.
*
* @return
* possible object is
* {@link String }
*
*/
@Basic
@Column(name = "G_", length = 255)
public String getG() {
return g;
}
/**
* Sets the value of the g property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setG(String value) {
this.g = value;
}
}
余分なアンダースコア @Column(name = "G_", length = 255) は、休止状態が無効な列マッピングについて不平を言うため、コードを壊しています。
私がこれまでに試したことは、問題に影響を与えませんでした:- 1) demo.xsd のインライン カスタム バインディング
<xs:annotation>
<xs:appinfo>
<jxb:property name="G" />
</xs:appinfo>
</xs:annotation>
と
<xs:annotation>
<xs:appinfo>
<orm:attribute-override name="G">
<orm:column name="G" />
</orm:attribute-override>
</xs:appinfo>
</xs:annotation>
ここで何が欠けていますか、誰かお願いします!
更新: 以下のHibernateクエリ: - Hibernate:
DEMO demo0_ から PLAYERID1_0_ として demo0_.PLAYERID、G_2_0_ として demo0_.G_ を選択します。
痕跡:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'demo0_.G_' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
当然のことながら、実際の列はGであり、hyperjaxb によって生成されたG_ではないため、(手動で) G に変更すると、この問題が解決します