is not mapped problem, spring loading Jar in config file

Source: Internet
Author: User

The error is as follows:

Org.hibernate.hql.ast.QuerySyntaxException:Content is not mapped [select New Content (T.id,t.name,t.values, T.systemtype,t.type,t.sortnumber) from Content t where 1=1 and T.type =? and T.systemtype =? ORDER BY T.sortnumber Desc]
At Org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister (sessionfactoryhelper.java:158)
At Org.hibernate.hql.ast.tree.FromElementFactory.addFromElement (fromelementfactory.java:87)
At Org.hibernate.hql.ast.tree.FromClause.addFromElement (fromclause.java:70)
At Org.hibernate.hql.ast.HqlSqlWalker.createFromElement (hqlsqlwalker.java:255)
At Org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement (hqlsqlbasewalker.java:3056)
At Org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList (hqlsqlbasewalker.java:2945)
At Org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause (hqlsqlbasewalker.java:688)

Scenario Description:

Content in the jar file packaged with the A project, there is no problem with the use of a project alone.

The spring configuration of the B project is as follows:

<property name= "Mappingdirectorylocations" >
<list>
<value>classpath:/com/mythink/entity/</value>
</list>
</property>

Internet lookup reason, when using spring to load the configuration file in the jar package, wildcard characters are not supported and require one introduction.

To verify, change the configuration to the following:

<property name= "Mappingresources" >
<list>
<value>com/mythink/entity/common/Content.hbm.xml</value>
</list>
</property>

Restart Access, and sure enough, no problem. But this is going to be a load config file, super hassle. Continue searching!!

Hey, you really found a good way to change the configuration as follows:

<!--load the configuration file in the jar package to solve the is mapped problem--
<property name= "Mappingjarlocations" >
<list>
<value>/WEB-INF/lib/xxx.jar</value>
</list>
</property>
<property name= "Mappingdirectorylocations" >
<list>
<value>classpath:/com/mythink/entity/</value>
</list>
</property>

Restart, the hibernate configuration file can be loaded normally.

is not mapped problem, spring loading Jar in config file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.