2015-07-10 67 views
0

我知道有下文,但我這個XML文件非常愚蠢的錯誤無法修復一樣。我使用與Hibernate混合策略,我想只有一個子類作爲表的策略,其餘爲joined.Here是XML。我知道這應該是愚蠢的,但我不是在XML映射我使用註釋而我現在用XML HBMS結識元素類型的內容「加入」必須再選擇匹配「(,評論,鑰匙,(財產?|?多到一個|成分|

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping> 
    <class table="PAYMENT" name="parent.Payment"> 
     <id name="id" type="long" column="PAYMENT_ID"> 
      <generator class="native" /> 
     </id> 
     <discriminator column="PAYMENT_TYPE" type="string"/> 
     <property name="amount" column="AMOUNT" /> 
     <subclass discriminator-value="CREDIT" 
     name="child.CreditCardPayment"> 
      <join table="CREDIT_PAYMENT"> 
       <property name="creditCardType" column="CCTYPE" type="string"/> 
      </join> 
     </subclass> 
     <subclass name="child.CashPayment" discriminator-value="CASH"> 
      <join table="CASH_PAYMENT"> 
       <property name="cashType" column="CATYPE" type="string"/> 
      </join> 
     </subclass> 
     <subclass name="child.ChequePayment" discriminator-value="CHEQUE"> 
     </subclass> 
    </class> 
</hibernate-mapping> 

例外是這樣的:

Caused by: org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 11; The content of element type "join" must match "(subselect?,comment?,key,(property|many-to-one|component|dynamic-component|any)*,sql-insert?,sql-update?,sql-delete?)". 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) 

回答

0

嘗試指定的<key column=" "/>column="PAYMENT_ID"如下:

<hibernate-mapping> 
    <class table="PAYMENT" name="parent.Payment"> 
     <id name="id" type="long" column="PAYMENT_ID"> 
      <generator class="native" /> 
     </id> 
     <discriminator column="PAYMENT_TYPE" type="string"/> 
     <property name="amount" column="AMOUNT"/> 
     <subclass discriminator-value="CREDIT" 
     name="child.CreditCardPayment"> 
      <join table="CREDIT_PAYMENT"> 
       <key column="PAYMENT_ID"/> 
       <property name="creditCardType" column="CCTYPE" type="string"/> 
      </join> 
     </subclass> 
     <subclass name="child.CashPayment" discriminator-value="CASH"> 
      <join table="CASH_PAYMENT"> 
       <key column="PAYMENT_ID"/> 
       <property name="cashType" column="CATYPE" type="string"/> 
      </join> 
     </subclass> 
     <subclass name="child.ChequePayment" discriminator-value="CHEQUE"> 
     </subclass> 
    </class> 
</hibernate-mapping> 
+0

最後一個我不想加入...我想有組合策略.. – Abhijeet

+0

更新了答案! – Arpit

相關問題