2

I am getting an error when trying to place lazy true to the following propety:

 <many-to-one name="ProductCategory" class="com.BiddingSystem.Models.Category" fetch="join" lazy="true">
            <column name="PRODUCTCATEGORY" />
        </many-to-one>

Stack Trace:

Caused by: org.xml.sax.SAXParseException: Attribute "lazy" with value "true" must have a value from the list "false proxy no-proxy ".
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.validateDTDattribute(XMLDTDValidator.java:1414)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1333)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1940)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:764)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)

4 Answers 4

5


lazy="true" is not allowed in many-to-one mapping. You should user false/proxy/no-proxy.
Thanks.

Sign up to request clarification or add additional context in comments.

2 Comments

but among the three false/proxy/no-proxy which one should i use if i dont want the category object to load
@Noor, if you feel the answer was useful, please upvote it :-)
5

From Hibernate 3.1+ lazy="true" was removed from the DTD (which is what is causing your error). you should use lazy="no-proxy" instead.

Comments

1

Actually if you use lazy="no-proxy", you will need to instrument your code. For default lazy loading, you should use "proxy".

Also note that lazy="true/false/extra" is valid for Collection associations.

Comments

1
Attribute "lazy" with value "true" must have a value from the list "false proxy no-proxy ".

It should have one of the values inside the list:

false, proxy, no-proxy

Your answer is already in your stack trace.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.