我要求在JPA注释的java pojos中忽略自动生成的hjid。我可以使用外部绑定来实现这一点,但是当我尝试使用JAXB内联自定义执行相同的操作时,它仍然会创建hjid。我在这里失踪了。
Master.xsd
GET /register 304 670.944 ms - -
GET /bootstrap/css/bootstrap.min.css 304 9.677 ms - -
GET /dist/css/AdminLTE.min.css 304 7.780 ms - -
GET /plugins/iCheck/square/blue.css 304 7.291 ms - -
GET /plugins/jQuery/jQuery-2.2.0.min.js 304 2.312 ms - -
GET /bootstrap/js/bootstrap.min.js 304 2.259 ms - -
GET /plugins/iCheck/icheck.min.js 304 2.076 ms - -
GET /bootstrap/fonts/glyphicons-halflings-regular.woff2 304 0.468 ms - -
GET /plugins/iCheck/square/blue.png 304 0.439 ms - -
{ method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 'q' ],
__knexQueryUid: '99707783-2767-4c37-ae4c-0bd31f98427d',
sql: 'select * from `Clients` where `UserName` = ?' }
User Not Found
Stat : 0
{ method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings:
[ '41040',
false,
'ameya.pandya@securelayer7.net',
'q',
'2e96772232487fb3a058d58f2c310023e07e4017c94d56cc5fae4b54b44605f42a75b0b1f358991f8c6cbe9b68b64e5b2a09d0ad23fcac07ee9a9198a745e1d5',
'70b32fc5adc4d2fa6ad5a40d9b6bfe4acc745d0c9c71d47a8266a4d54868198acb29644dc6133fb51cd682dcf1fc72a52278a51ade397ed7f2a38f8ec809e0bf',
'q',
'q',
'q' ],
__knexQueryUid: 'dee0340f-c247-4608-a29e-da984cc13e49',
sql: 'insert into `Clients` (`ActivationCode`, `ActivationStatus`, `Email`, `FirstName`, `HashPassword`, `Id`, `LastName`, `MiddleName`, `UserName`) values (?, ?, ?, ?, ?, ?, ?, ?, ?)' }
POST /register - - ms - -
{ method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 'q' ],
__knexQueryUid: 'a58fe912-3a9e-4af0-85ca-e1ba2aa9559b',
sql: 'select * from `Clients` where `UserName` = ?' }
Stat : 1
POST /register 200 105.596 ms - 3234
外部绑定有效,但我需要避免使用外部绑定 的 bindings.xjb
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm">
<xs:annotation>
<xs:appinfo>
<hj:persistence>
<hj:default-generated-id transient="true"
name="hjid" />
</hj:persistence>
</xs:appinfo>
</xs:annotation>
<xs:complexType name="master">
<xs:sequence>
<xs:element name="PLAYERID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<hj:id>
<orm:column name="PLAYERID" />
</hj:id>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="BIRTHYEAR" type="xs:string" />
<xs:element name="BIRTHMONTH" type="xs:string" />
<xs:element name="BIRTHDAY" type="xs:string" />
<xs:element name="BIRTHCOUNTRY" type="xs:string" />
<xs:element name="BIRTHSTATE" type="xs:string" />
<xs:element name="BIRTHCITY" type="xs:string" />
<xs:element name="DEATHYEAR" type="xs:string" />
<xs:element name="DEATHMONTH" type="xs:string" />
<xs:element name="DEATHDAY" type="xs:string" />
<xs:element name="DEATHCOUNTRY" type="xs:string" />
<xs:element name="DEATHSTATE" type="xs:string" />
<xs:element name="DEATHCITY" type="xs:string" />
<xs:element name="NAMEFIRST" type="xs:string" />
<xs:element name="NAMELAST" type="xs:string" />
<xs:element name="NAMEGIVEN" type="xs:string" />
<xs:element name="WEIGHT" type="xs:string" />
<xs:element name="HEIGHT" type="xs:string" />
<xs:element name="BATS" type="xs:string" />
<xs:element name="THROWS" type="xs:string" />
<xs:element name="DEBUT" type="xs:string" />
<xs:element name="FINALGAME" type="xs:string" />
<xs:element name="RETROID" type="xs:string" />
<xs:element name="BBREFID" type="xs:string" />
<xs:element name="IMAGE" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
答案 0 :(得分:1)
看起来不错,但您可能需要声明:
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
jaxb:extensionBindingPrefixes="hj orm"
jaxb:version="2.1"
在您的架构上。
请参阅this example:
<xs:complexType name="four">
<xs:sequence>
<xs:element name="id" type="xs:int" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<hj:id>
<orm:column name="FOUR_CUSTOM_ID"/>
<orm:generated-value strategy="SEQUENCE" generator="four-sequence"/>
<orm:sequence-generator name="four-sequence" sequence-name="FOUR_SEQ"/>
</hj:id>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
这与你已经做过的事情完全相同。只有您可能遗失jaxb:extensionBindingPrefixes="hj orm"
。