springmvc+hibernate 实体类映射错误

图片说明type Exception report

message Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Users is not mapped [from Users u where u.loginName='ss' and u.password='aa']

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Users is not mapped [from Users u where u.loginName='ss' and u.password='aa']
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

org.hibernate.hql.ast.QuerySyntaxException: Users is not mapped [from Users u where u.loginName='ss' and u.password='aa']
org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:257)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
myplan.dao.impl.UserDaoImpl.login(UserDaoImpl.java:34)
myplan.service.impl.UserServiceImpl.login(UserServiceImpl.java:21)
myplan.action.UserController.login(UserController.java:28)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)![图片说明](https://img-ask.csdn.net/upload/201605/24/1464029672_578711.png)图片说明

2个回答

把映射配置文件贴出来看看

保守估计是少了jar包了,,,

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
hibernate的实体类映射问题
小弟刚接触hibernate 再用其做个电子商务网站的时候碰到了问题rn不清楚该如何才能设计好实体类rn就拿订单类跟用户类来说吧rn两者是有关系的 我该如何设计这2个实体类呢?rn订单类属性:属性1---订单IDrn 属性2---用户类(还是用户ID?)rnrn貌似订单类的属性有用户类的时候 如果save订单类到表里的时候 用户类也要被保存到表里面 但是这个用户已经是存在了的 这样就会出错rn请问订单类的属性2是用户类好还是用户ID好?rnrn
Hibernate实体类映射(Annotation)
一对一关联        单向:               主键关联: @OneToOne(cascade=”…”,…)                      @PrimaryKeyJoinColumn               外键关联 ( 默认方式 ) :                      @OneTo...
hibernate疑难(@注解配置实体类映射 )
我用@注解配置实体类映射 rn不知道是不是表没有主键的原因,我查出来的数据都是第一条,比如我查到30条数据,但是30条都是第一条的 数据。rn请问@注解配置实体类映射 要怎么配置 rn我的实体类是rn@Entity rn3.@Table(name = “tb_cat”) rn4.public class Cat rn @GenericGenerator(name = "generator", strategy = "increment") rn @Id //我没有id 但是去掉就会报错rn @GeneratedValue(generator = "generator") rn7. private String date; rn8. @Column(name = “name”) rn9. private String name; rn11. @Column(name = “createDate”) rn12. private int number; rn13. //….getter、setter方法省略 rn14. rnrnrn配置大致是这样,代码都没错,但是就是查出来的数据都是第一条rn
Hibernate自动生成数据库表映射实体类
private static void printTableMetaInfo(Session session) { Connection connection = session.connection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet result = metaData.getColumns(null, null, NameOfTable, null); String strInJava = ""; String typeInJava; while (result.next()) { String columnName = result.getString(4); if ("stampTime".equalsIgnoreCase(columnName)) { continue; } int columnType = result.getInt(5); String nameFirstLetterLower = columnName.substring(0, 1).toLowerCase() + columnName.substring(1); switch (columnType) { case Types.VARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.NVARCHAR: case Types.CHAR: typeInJava = "String"; break; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: typeInJava = useInteger ? "Integer" : "int"; break; case Types.TIMESTAMP: case Types.BINARY: typeInJava = "Calendar"; break; case Types.DECIMAL: typeInJava = "BigDecimal"; break; case Types.BIGINT: typeInJava = "BigInteger"; break; case Types.LONGVARBINARY: typeInJava = "byte[]"; break; case Types.DATE: typeInJava = "Calendar"; break; default: throw new Exception("Unknown type " + columnType + " and column is " + columnName); } strInJava += " private " + typeInJava + " " + nameFirstLetterLower + ";\n"; // strInHibernate += "<property name=\"" + nameFirstLetterLower + "\" column=\"" + columnName + "\"/>\n"; } String str = "import javax.persistence.Entity;\n" + "import javax.persistence.Id;\n" + "import javax.persistence.Table;\n" + "import java.util.Calendar;\n\n"; str += "@Entity\n"; str += "@Table(name=\"$\")\n".replace("$", NameOfTable); str += "public class $ {\n".replace("$", NameOfTable.substring(2)); str += "\n @Id\n"; str += strInJava; str += "}"; System.out.println(str); StringSelection stringSelection = new StringSelection(str); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); } catch (Exception e) { e.printStackTrace(); }
记录Hibernate映射实体类@注解
映射自增注解@Id @GeneratedValue(strategy = GenerationType.AUTO) //@Column(name = "id")/**对应数据库中的字段名称,这里可以不写,默认映射的是跟字段同名*/ private Integer id;映射自定义主键(该主键在新增时需要手动设置)@Id @GeneratedValue(generator="pkgen") @Gene
hibernate实体类映射不到的问题
由于业务需要,我们在我们的公司的项目里创建了两个entity,我们公司用的项目框架是spring、springMVC、hibernate,两个entity的路径截图如下: 下面那个画红色圈的是我新建的entity,之前都是一个entity,tomcat启动后不会报错,现在加了一个entity后控制台就报错了,错误如下: 其实错误信息已经很明显了,提示我的
Springmvc 页面映射错误
Springmvc 首页映射错误 错误页面: 错误原因: tomcat 默认有一个在未输入请求页面是寻找首页的配置,如: http://localhost:8080/ 默认找 web 项目根目录下的 index.html,index.htm,index.jsp 由于我的项目根目录下有一个自动生成的 index.jsp 文件 导致项目默认显示 index.jsp 页面 处理方法: 1. 将 in...
springMVC 实体类的时间字符串映射注解
@DateTimeFormat(pattern="yyyy-MM-dd")     private Date registerDate;
Hibernate映射错误
请问我用hibernate映射数据库,抱错,希望大家帮我分析一下:包错信息如下:rnrnlog4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).rnlog4j:WARN Please initialize the log4j system properly.rnorg.hibernate.MappingException: Unknown entity: ch03.hibernate.Userrn at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:514)rn at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1302)rn at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:89)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)rn at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)rn at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)rn at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530)rn at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)rn at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)rn at ch03.hibernate.Test.main(Test.java:19)rnrn以下是测试程序rnrnUser.javarnrnpackage ch03.hibernate;rnrnpublic class Userrnrn private int id;rn private String username;rn private String password;rn private String email;rn rn public void setId(int id)rn rn this.id = id;rn rn rn public int getId()rn rn return this.id;rn rn rn public void setUserName(String userName)rn rn this.username = userName;rn rn rn public String getUserName()rn rn return this.username;rn rn rn public void setPassword(String password)rn rn this.password = password;rn rn rn public String getPassWord()rn rn return this.password;rn rn rn public void setEmail(String email)rn rn this.email = email;rn rn rn public String getEmail()rn rn return this.email;rn rnrnrnrn测试类 Test.javarnrnpackage ch03.hibernate;rnrnimport org.hibernate.*;rnimport org.hibernate.cfg.*;rnrnrnpublic class Test rnrn public static void main(String[] args)rn rn tryrn rn SessionFactory sf = new Configuration().configure().buildSessionFactory();rn Session session = sf.openSession();rn Transaction tx = session.beginTransaction();rn User user = new User();rn user.setUserName("wujunjie");rn user.setPassword("123");rn session.save(user);rn tx.commit();rn session.close();rn rn catch(HibernateException e)rn rn e.printStackTrace();rn rn rnrnrnrn以下是几个配置文件:rnrnhibernate.cfg.xmlrnrnrnrnrnrnrnrn rn scottrn jdbc:oracle:thin:@localhost:1521:ORACrn org.hibernate.dialect.Oracle9Dialectrn OracleConnectionrn tigerrn oracle.jdbc.driver.OracleDriverrn rn rnrnrnrn用户配置文件 User.hbm.xmlrnrnrn rn rn rn rn rn rn rn rn rn rn rnrn另外还有几个问题:rnrn rn rn这里面name的名字是否要和类里面的字段名一模一样,与数据库的也是否要求一致.rnrn还有到了最后一步怎么和类映射!也就是说我将表已经导人到了工程里面,最后映射表不只到怎么弄望大家赐教.版本 MyEclipse 5.0.1 因为原来用的老版本在表那直接点右键 Create Hibernate Mapping,但是现在这个版本我却不知道怎么直接映射,有谁知道吗?rnrn
【Hibernate】映射文件类型错误
hibernate映射文件中的“type”类型错误会报如下异常:java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.hibernate.type.IntegerType.set(IntegerType.java:64) at org.hibernate.type.Nu
hibernate many-to-many 映射错误
程序中配置了新闻和栏目的多对多映射。无论是新闻表还是栏目表的one-to-many和one-to-one都没有错,但是一旦修改成many-to-many就会产生以下错误。求 助高人了!rnorg.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.tsinghuatec.cms.model.TfCpXwLmDO.tfCpXwLmYses#1]rn at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)rn at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)rn at org.hibernate.loader.Loader.loadCollection(Loader.java:2022)rn at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)rn at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)rn at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)rn at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)rn at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:366)rn at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)rn at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)rn at com.tsinghuatec.sso.SsoUsermapDaoTest.testFindBycjrxm(SsoUsermapDaoTest.java:45)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at junit.framework.TestCase.runTest(TestCase.java:154)rn at junit.framework.TestCase.runBare(TestCase.java:127)rn at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)rn at junit.framework.TestResult$1.protect(TestResult.java:106)rn at junit.framework.TestResult.runProtected(TestResult.java:124)rn at junit.framework.TestResult.run(TestResult.java:109)rn at junit.framework.TestCase.run(TestCase.java:118)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnCaused by: java.sql.SQLException: ORA-00942: table or view does not existrnrn at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)rn at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)rn at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)rn at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622)rn at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180)rn at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:419)rn at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:895)rn at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:451)rn at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:985)rn at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)rn at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2928)rn at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)rn at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)rn at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)rn at org.hibernate.loader.Loader.doQuery(Loader.java:697)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)rn at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)rn ... 22 morernrn配置文件是这样rnrn rn rnrnrn rn column name="XWID" length="36" not-null="true">rn 新闻IDrn rn rn rnrnrn这样配置时的错误是取tfCpXwFjs没有问题,但是取tfCpXwLmYses就出错了。n[b]问题补充:[/b]nrn 这种我也试过的。问题依旧。
hibernate映射错误!
哪位也碰到了数据库中的字段为bit类型 让Myeclipse自动映射 ,本来是Byte类型的 怎么成了rnString 呢。这个又在工具中如何改?rn高手指点下。rnrnrn[color=#339966]--------------------------------------------------------------------rn以下内容为自动编辑的内容,并非楼主的发贴内容,此仅用于显示而已,并无任何其他特殊作用rn楼主【zhouzongxi】截止到2008-08-05 00:19:43的历史汇总数据(不包括此帖):rn发帖的总数量:19 发帖的总分数:225 每贴平均分数:11 rn回帖的总数量:208 得分贴总数量:78 回帖的得分率:37% rn结贴的总数量:19 结贴的总分数:225 rn无满意结贴数:4 无满意结贴分:55 rn未结的帖子数:0 未结的总分数:0 rn结贴的百分比:100.00% 结分的百分比:100.00% rn无满意结贴率:21.05 % 无满意结分率:24.44 % rn敬礼![img=http://p.blog.csdn.net/images/p_blog_csdn_net/java2000_net/381633/o_medal1.gif][/img][/color]rn取消马甲机器人,请点这里:[url=http://www.java2000.net/mycsdn/robotStop.jsp?usern=zhouzongxi][/url]
关于hibernate的映射错误
public Object doInHibernate(Session session)throws HibernateException, SQLException rn Query query = session.createQuery("from PdnOrderInfo"); rn return query.list(); rn rnrn我的bean如下 rn rnrn rnrn rn rn rn rnrn rn rn rn rn rn rn rnrnrn为什么结果报下面的错误 rnorg.hibernate.hql.ast.QuerySyntaxException: PdnOrderInfo is not mapped [from PdnOrderInfo as pdnOrderInfo where pdnOrderInfo.pdnOrderAddrId=:addressId and pdnOrderInfo.pdnOrderType=:pdnOrderType and pdnOrderCodeA='0' or pdnOrderCodeB='0' or pdnOrderCodeC='0' or pdnOrderCodeD='0' or pdnOrderCodeE='0']
hibernate用注解配置实体类的映射-问题01
hibernate4.3.5用注解配置实体类的映射,相当于Teacher.hbm.xml文件, Teacher.java代码: @Entity @Table(name="t_teacher") public class Teacher { private long id; private String name; @Id @GeneratedValue(generator="_n
Hibernate忽略实体类里字段的映射
@Transient public String getEndDate() { return endDate; } public void setEndDate(String endDate) { this.endDate = endDate; }
hibernate实体类与数据表映射的两种方式
1、传统方法是通过XX.hbm.xml映射文件      注意:1)JPA jar包在hibernate3.6之后被放入hibernate-core包中。               2) 2、java5.0以后可以通过注解方式取代XX.hbm.xml映射文件      注意1)需要在Hibernate配置文件中注册该实体类:            2)实体类的属性声明顺序和数
hibernate 一个实体类映射多个表的方法
         首先得承认我学Hibernate这东西时间还比较短,了解太浅,遇到这个问题的确不知道怎么处理,但是在网上搜索页没有找到资料,多亏 jinnianshilongnian 老兄给我了一个链接,看到,的确在Hibernate中有很简单的处理方式,在这里表示感谢。        真的是活到老学到老。而且,这也坚定了我自顶向下的设计理念,我坚持先从业务分析中得到对象再考虑数据库的...
Hibernate 映射实体类中的3种集合类型
一、Map:一组键值对应的无序,唯一的数据。 二、Set:一组无序,唯一的数据    该集合是用的最多的。 三、List:一组有序、不唯一的数据。     &amp;lt;!-- List 集合的节点 --&amp;gt; &amp;lt;bag name=&quot;emps&quot;&amp;gt; &amp;lt;key column=&quot;deptno&quot;/&amp;gt; &amp;lt;one-to-many class=&quot;org.entity...
《Hibernate学习笔记二》:表与实体类的映射方法
Hibernate学习笔记二:表名与实体类名不一致/表中的列名与实体属性名不一致的映射方法在使用Hibernate 中,我们最好尽量使得实体类的名字与表的名字 、实体类的属性名与表的列名尽量相同,这样可以省去很多的麻烦 。但是,在我们的实际项目中,可能会遇到实体类的名字与表的名字不一致 的情况 。当遇到这样情况,我们应该怎么办呢??如果我们使用的是Annotation ,则比较好办。看实际例子,
【Hibernate】从入门到精通(三)映射实体类
在上篇博客中,我们把hibernate的基本环境搭建好了。接下来就开始我们核心的内容介绍。我们知道Hibernate是一个ORM框架,即对象关系映射。那么它是如何将我们程序的对象映射成关系表的呢?这是本文我们要谈论的内容。 展示的思路是,程序中创建一个类,通过配置等操作,最终将对象的属性映射到数据库中的一个表。对象的属性变成了表里的字段。步骤一:新建类此步就不赘述了。该类代码如下。package
hibernate主要配置文件整合-----实体类映射--持久化
hibernate主要配置文件整合 结构图: 实体类映射文件,名称格式:XX.hbm.xml &amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;amp;gt; &amp;amp;lt;!DOCTYPE hibernate-mapping SYSTEM &amp;quot;http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd&amp;quot; &amp;amp;gt; &amp
Myeclipse自动生成Hibernate配置文件及实体类映射ORM
Myeclipse自动生成Hibernate配置文件及实体类映射ORM配置文件--hibernate方式
Hibernate映射的Entity实体类封装案例
/** * &lt;p&gt; * Title:User.java */ package cn.surveystore.smk.entity; import java.io.Serializable; import java.sql.Timestamp; import java.util.Date; import java.util.Set; import javax.persisten...
关于Spring整合Hibernate,映射实体类is not mapped
用了两种方式:rn1、rn[code=java] rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rn rn vo/Customer.hbm.xmlrn rn rn [/code]rn不可行,报错没有找到映射rn2、rn[code=java] rn rn rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn [/code]rnhibernate.cfg.xml中: rn可行,可以执行成功rnrn搞不懂为什么第一种方式不行,求解
请问hibernate中的两种实体类映射
刚接触hibernate不久rnrn当是一对多或者多对一时,可以用等集合映射的key和element对,这时只要写一个实体类配置文件就可以了;rn也可以在实体类的*.hbm.xml中配置集合元素,不过要所有的实体类都写*.hbm.xml配置文件;rnrn这两种方式各自该在什么情况下使用啊?rn请各位赐教!
hibernate 无主键的表映射实体类
保存一个实体类的时候报错了 : org.hibernate.AssertionFailure: null id in xxx.xxx.xxx排除了关键字的因素后, 才发现表没有主键 . 修改后好了. class name="com.xx.xx" table="xx" > "name" type="string" column = "name"/> "age"/>
lombok、hibernate配对实体类映射注解
lombok、hibernate配对实体类映射注解 hibernate注解实体类时,会在每个get方法上加@Column,@Id等注解。使用lombok去掉get/set怎么处理hibernate的注解呢? import javax.inject.Inject; import javax.persistence.Id; import javax.persistence.Column; import...
Hibernate如何配置实体类到数据库表的映射
Hibernate的核心功能是根据数据库到实体类的映射,自动从数据库绑定数据到实体类。使我们操作实体类(Java对象)就能对数据库进行增、删、查、改,而不用调用JDBC API使数据操作变得简单而不繁琐。本文就主要讲解Hibernate的映射文件的映射机制,但本文讲解的重点在于通过Hibernate如何配置实体类到数据库表的映射,至于数据库表(或实体类)之间的各种关联关系的映射会在后面的文章中讲到
关于SpringMVC和Hibernate的Entity实体类的问题【谢谢】
各位大哥大姐,小弟最近在研究SpringMVC。有个问题请教rn SpringMVC有个Entity实体类user,为了获取页面的输入的数据,比如username和password。rn获取后存入数据库,但是我在Enitiy实体类上加了@Entity和@Table后,就无法获取页面数据,他就被当成hibernate的数据库表对应的类了。难道就一个简单的页数输入数据,就要写两个实体类?一个SpringMVC用,一个Hibernate用?不能共用一个吗?还是我的模式错了?请个各位大哥大姐解惑,谢谢了。
Hibernate的配置文件的映射many-to-one错误
先看一下错误 虽然,这么多错误挺吓人的,还有SessionFactory为空,但是其实就一个错误文件是这样的Customer.javapackage ch06.pojo;import java.io.Serializable;/** * Customer entity. @author MyEclipse Persistence Tools */public class Custome
idea spring托管hibernate并生成hibernate 实体类映射
第一种方式:勾选生成JPA注解,并在applicationContext.xml中的sessionFactory的bean标签中添加: name="packagesToScan" value="model"/> 这样不需要*.hbm.xml文件,spring会扫描model包下的类,并根据jpa注解与对应的表建立关联 第二种方式:生成model.hbm.xml,不勾选JPA注解,这样在mod
hibernate实体类
hibernate实体类的属性名不能是key private String key; key是hibernate的关键字
奇怪的错误 springMVC hibernate commons-fileupload-1.2.1
最近自己做了一个网站,用的是springMVC+spring2.0+Hibernate3.0rn数据库是MYSQL5.0 ,开发平台是myeclisp6.0GA.系统是win XP。rn运行在TOMCAT5.0上。在系统里因为要上传,所以做了一个上传进度条。而且用拦截器做了一个简单的权限控制。并且用定时器在每天晚上都执行一段代码实现文件有效,失效的判断。rnrn还用了poi-3.5-FINAL-20090928.jar导出excel文件rnrn但是系统刚刚开始部署上去的时候,一切正常,但是过一段时间之后会出现很多空指针错误,而且网站也会访问不了。但是同一个tomcat下的其他网站可以正常访问。当tomcat重启之后一切又正常了。rn以下是tomcat的日志错误。rn[code=Java]rnStandardWrapperValve[dispatcherServlet]: Servlet.service() for servlet dispatcherServlet threw exceptionrnjava.lang.NullPointerExceptionrnjava.lang.NullPointerExceptionrn at org.apache.jsp.jsp.main.search_jsp._jspService(search_jsp.java:456)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)rn at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)rn at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)rn at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)rn at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:111)rn at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)rn at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:965)rn at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:744)rn at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)rn at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)rn at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)rn at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Thread.java:595)rnApplicationDispatcher[/InterPolicy]: Servlet.service() for servlet jsp threw exceptionrnjava.lang.NullPointerExceptionrn at org.apache.jsp.jsp.main.search_jsp._jspService(search_jsp.java:456)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)rn at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)rn at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)rn at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)rn at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:111)rn at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)rn at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:965)rn at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:744)rn at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)rn at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)rn at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)rn at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Thread.java:595)rn[/code]rnrn
Mysql映射java实体类
一个非常牛逼的mysql表映射java实体类,但是用的时候注意修改你的数据库名,用户名,密码等等
实体类映射枚举类型
[code=&quot;java&quot;] @Enumerated(EnumType.ORDINAL) private Assign assign; [/code] 数据库中字段assign tinyint
mybatis自动生成实体类映射
mybatis自动生成实体类映射,建立好数据库后,修改好映射关系,既可以自动生成实体类和xml文件
急!!!NHibernate 映射实体类
我用NHibernate 连接数据库 写了一个实体类xml 来映射 但是 我运行出现rnrn一个'异常的类型NHibernate.MappingException发生在NHibernate.DLL但不是信息处理用户代码附加条件:未知的实体类:Student.BLL.AbroadInforn 大家帮忙 没用过NHibernate 不知道具体都做什么内容
@注解配置实体类映射
实体一般有id,普通属性,集合属性等,分别对应数据库中的主键,普通列,外键。@注解配置中,实体类@Entity注解,用@Table指定对应的数据表,@Id配置主键。用@Column配置普通属性,用@OneToMany、@ManyToOne、@OneToOne、@ManyToMany配置实体间的关系等。 [code=&quot;java&quot;] //...导入一系列包 @Entity @Table(nam...
mybatis数据库和实体类的映射?
[size=24px]用mybatis-generator-core-1.3.2.jar这个生成的java bean没有多表关联关系...比如User表里边的role_id 就变成了生成的User实体类中的一个字段role_id了,而不是一个Role对象,上网搜了搜资料说mybatis-generator只能做单表查询。。。这个意思就是还要修改mybatis-generator-core-1.3.2.jar生成的代码了。rn实际开发中,都是怎么对应实体类呢?难道不用mybatis-generator-core-1.3.2.jar这个工具,自己手动code出mapper bean类吗?[/size]
sqlmap,数据库表映射实体类
sqlmap,ibatis与mysql 结合的实体对象生成
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制