Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > BOOK: Professional Hibernate
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Hibernate
This is the forum to discuss the Wrox book Professional Hibernate by Eric Pugh, Joseph D. Gradecki; ISBN: 9780764576775
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Hibernate section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 9th, 2005, 06:41 AM
Registered User
 
Join Date: Oct 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Table-per-Class Hierarchy on page 110

I had follow the example in the book. There are one example to persist Table-per-Class Hierarchy on page 110. It can't work, the error show like this,

[ERROR] 07:18 (XMLHelper.java:error:48)
Error parsing XML: XML InputStream(10) Attribute "insert" must be declared for element type "discriminator".

18:07:18,922 - ERROR net.sf.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(10) Attribute "insert" must be declared for element type "discriminator".
1072 [main] ERROR net.sf.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(10) Attribute "insert" must be declared for element type "discriminator".
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: eg/hibernate/mapping/dataobject/CD.hbm.xml
    at net.sf.hibernate.cfg.Configuration.addResource(Con figuration.java:336)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Con figuration.java:990)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Con figuration.java:946)
    at net.sf.hibernate.cfg.Configuration.configure(Confi guration.java:874)
    at de.laliluna.library.HibernateSessionFactory.curren tSession(HibernateSessionFactory.java:57)
    at de.laliluna.library.test.LibraryTest.main(LibraryT est.java:43)
Caused by: net.sf.hibernate.MappingException: invalid mapping
    at net.sf.hibernate.cfg.Configuration.addInputStream( Configuration.java:284)
    at net.sf.hibernate.cfg.Configuration.addResource(Con figuration.java:333)
    ... 5 more
Caused by: org.xml.sax.SAXParseException: Attribute "insert" must be declared for element type "discriminator".
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(ErrorHandlerWrap per.java:236)
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java:172)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:382)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:316)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.addDTDDefaultAttrsAndValidate(XMLDTDVali dator.java:1306)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.handleStartElement(XMLDTDValidator.java: 1971)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.emptyElement(XMLDTDValidator.java:816)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.scanStartElement(XMLNSDocumentScann erImpl.java:322)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(XMLDocumentFragmentScannerImpl.java:1693)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1242)
    at org.dom4j.io.SAXReader.read(SAXReader.java:339)
    at net.sf.hibernate.cfg.Configuration.addInputStream( Configuration.java:283)
    ... 6 more
Exception in thread "main" java.lang.NullPointerException
    at de.laliluna.library.HibernateSessionFactory.curren tSession(HibernateSessionFactory.java:65)
    at de.laliluna.library.test.LibraryTest.main(LibraryT est.java:43)


I have wrote hbm.xml like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="eg.hibernate.mapping.dataobject">
 <class discriminator-value="CD"
  name="eg.hibernate.mapping.dataobject.CD" table="CD">
  <id name="id" type="int">
   <generator class="native"/>
  </id>
  <discriminator column="cd_type" force="false" insert="true" length="2"/>
  <property name="title"/>
  <property name="purchaseDate" type="date"/>
  <property name="artist"/>
  <property name="cost" type="double"/>
  <subclass discriminator-value="SP" dynamic-insert="true" name="eg.hibernate.mapping.dataobject.CDSpecialEdi tion">
   <property name="newfeatures"/>
  </subclass>
  <subclass discriminator-value="IT" dynamic-insert="true" name="eg.hibernate.mapping.dataobject.CDInternatio nal">
   <property name="region"/>
   <property name="language"/>
  </subclass>
 </class>
</hibernate-mapping>

I would appreciate if you could suggest me what is wrong.

Thanks


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3, Page 110 ntonline1 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 2nd, 2011 10:06 AM
page class access jonbprime ASP.NET 2.0 Professional 0 January 1st, 2007 09:15 PM
apply css class to dynamically generated table row nikeshkm Javascript 2 September 28th, 2006 03:52 AM
help with class hierarchy wu4 XSLT 0 October 17th, 2005 01:58 PM
graphics class hierarchy using c++ chandankumarbehera C++ Programming 1 December 9th, 2003 06:38 AM



All times are GMT -4. The time now is 02:07 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.