mysql int类型值为null,hibernate映射错误的问题

我mysql数据库 有一个  numBack字段 ,是 int 类型的 ,



hibernate中 用  private int numBack; 与它对应





        <property name="numBack" column="numBack" type="int" length="5">

但当  数据库中 它的值是  NULL时 ,



就会报错 。



我想请问一下在  不把  数据库中  NULL改成 0的情况下, hibernate有没有什么措施可以解决 ?

2个回答

sql-type="number(1) default 0"
在sql-type里面定义数据库默认值

用private Integer numBack试一试

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
hibernate映射文件无法使用length指定int和Integer类型字段长度?

hibernate映射文件无法使用length指定int和Integer类型字段长度,正向生成的表中int和 Integer类型属性生成字段均为固定长度11 People.hbm.xml: ``` <hibernate-mapping package="com.wd.pojo"> <class name="People" table="t_people"> <id name="id" column="id" length="5"> <generator class="native"></generator> </id> <property name="age" length="5" column="age"></property> <property name="height" length="5" column="height" type="java.lang.Integer"></property> <property name="name" length="20"></property> </class> </hibernate-mapping> ``` 生成的mysql数据库中的ddl: ``` CREATE TABLE `t_people` ( `id` int(11) NOT NULL AUTO_INCREMENT, `age` int(11) DEFAULT NULL, `height` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ```

在hibernate中使用Integer做映射和使用int做映射之间的问题

我在做实体bean时用 Integer来映射的(如 private Integer abc;)。 但是在action里接收时却是用 int 来接收的(如 int a = entity.getAbc()),大量使用这样的方法有什么样的后果

用Hibernate映射mysql问题(Timestamp)

我知道这个是个常见问题,我已经看了论坛帖子和查阅相关资料,始终没找到好的解决方法,如果有空的帮解答下吧。 SessionInfo.hbm.xml [code="java"]<hibernate-mapping package="domaininvestment.model"> <class name="SessionInfo" table="SessionInfo"> <id name="id"> <generator class="native" /> </id> <property name="email" type="string" length="500" not-null="true" /> <property name="sessionID" type="string" length="200" /> <property name="clientIP" type="string" length="200" not-null="true" /> <property name="creationTime" type="timestamp" not-null="true" /> </class> </hibernate-mapping>[/code] SessionInfoDao.java [code="java"]public boolean sessionInfoExists(SessionInfo info) throws RuntimeException { if (info == null) { return false; } Session sess = DaoBase.currentSession(); try { String infoEmail = info.getEmail(); String infoClientIP = info.getClientIP(); Date infoCreationTime = info.getCreationTime(); if (infoEmail == null || infoClientIP == null || infoCreationTime == null) { return false; } int diff = Util.diffDays(new Date(), infoCreationTime); if (diff < 0 || diff > SessionInfo.COOKIE_MAX_DAYS) { return false; } Query q = sess.createQuery("from SessionInfo where email = :email and clientIP = :clientIP and creationTime =:creationTime") .setString("email", infoEmail) .setString("clientIP", infoClientIP) .setStrng("creationTime", infoCreationTime); Iterator itr = q.iterate(); if (itr.hasNext()) { return true; } else { return false; } } finally { DaoBase.closeSession(); }[/code] SessionInfoDaoTest.java [code="java"]@Test public void testSessionInfoExists() { SessionInfo info = null; assertFalse(dao.sessionInfoExists(info)); info = new SessionInfo(); assertFalse(dao.sessionInfoExists(info)); info.setEmail("test@dc.com"); assertFalse(dao.sessionInfoExists(info)); info.setSessionID("123456"); assertFalse(dao.sessionInfoExists(info)); info.setClientIP("192.168.1.1"); assertFalse(dao.sessionInfoExists(info)); info.setCreationTime(new Date()); assertFalse(dao.sessionInfoExists(info)); info = new SessionInfo(); info.setEmail("test@dc.com"); info.setClientIP("192.168.1.1"); info.setCreationTime(new Date()); Session sess = reopenSession(); sess.save(info); sess.flush(); closeSession(); assertTrue(dao.sessionInfoExists(info)); }[/code] 这里主要是timeStamp的问题,如果我把hql里面的creationTime去掉,即:"from SessionInfo where email = :email and clientIP = :clientIP " 我的测试就没问题,我把它加上后即使转成sqlDate也没用,不知道问题出在哪里?

hibernate 查詢字段(SET)為null 的數據

我想要某個對象下某個集合屬性為空的搜索結果,在寫hql語句的時候測試了N次一直不成功:select c from Category c where c.childCategory is null childCategory 是一個 集合,報 Caused by: java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use 錯誤 請問應該怎樣修改 [b]问题补充:[/b] 這是一個映射自身的類,為一對多 一個類別可以有多個子類別:childCategory 【code="java"] package com.bookseat.entitys; import java.util.HashSet; import java.util.Set; public class Category { private Integer categoryId; private String categoryName; public Integer getCategoryId() { return categoryId; } public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; } private Category fatherCategory; private Set<Category> childCategory = new HashSet<Category>(); private Set<Dishware> dishwaresByCategory = new HashSet<Dishware>(); public String getCategoryName() { return categoryName; } public void setCategoryName(String categoryName) { this.categoryName = categoryName; } public Set<Category> getChildCategory() { return childCategory; } public void setChildCategory(Set<Category> childCategory) { this.childCategory = childCategory; } public Set<Dishware> getDishwaresByCategory() { return dishwaresByCategory; } public void setDishwaresByCategory(Set<Dishware> dishwaresByCategory) { this.dishwaresByCategory = dishwaresByCategory; } public Category(String categoryName, Category fatherCategory, Set<Category> childCategory, Set<Dishware> dishwaresByCategory) { super(); this.categoryName = categoryName; this.fatherCategory = fatherCategory; this.childCategory = childCategory; this.dishwaresByCategory = dishwaresByCategory; } public Category getFatherCategory() { return fatherCategory; } public void setFatherCategory(Category fatherCategory) { this.fatherCategory = fatherCategory; } public Category() { } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((categoryId == null) ? 0 : categoryId.hashCode()); result = prime * result + ((categoryName == null) ? 0 : categoryName.hashCode()); return result; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Category other = (Category) obj; if (categoryId == null) { if (other.categoryId != null) return false; } else if (!categoryId.equals(other.categoryId)) return false; if (categoryName == null) { if (other.categoryName != null) return false; } else if (!categoryName.equals(other.categoryName)) return false; return true; } } [/code] 配置文件: [code="xml"] <?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 package="com.bookseat.entitys"> <class name="Category"> <id name="categoryId" column="category_id"> <generator class="increment" /> </id> <property name="categoryName" not-null="true" length="50" column="Category_Name" /> <set name="dishwaresByCategory" table="dishware_categorytable" cascade="save-update" lazy="false" > <key column="categoryId" /> <many-to-many column="dishwareId" class="Dishware" /> </set> <many-to-one name="fatherCategory" class="Category" fetch="select" cascade="save-update"> <column name="Category_parentId" /> </many-to-one> <set name="childCategory" inverse="true" lazy="false" cascade="save-update"> <key> <column name="Category_parentId" /> </key> <one-to-many class="Category" /> </set> </class> </hibernate-mapping> [/code] 按照yayg 兄的寫了搜索,不報錯但是仍然為空

hibernate3.3+mysql日期格式Date类型,无法进行相等的比较

hibernate3.3+mysql,数据库表是联合主键,其中一个为Date类型。此时对日期进行比较时,结果不正确。应该如何修改? 表结构: CREATE TABLE `temp` ( `room_id` int(11) NOT NULL, `priceDate` date NOT NULL, `value` varchar(20) DEFAULT NULL, PRIMARY KEY (`room_id`,`priceDate`) ); 映射文件: <composite-id name="id" class="com.boang.hotel.entity.TempId"> <key-property name="roomId" type="java.lang.Integer"> <column name="room_id" /> </key-property> <key-property name="priceDate" type="java.util.Date"> <column name="priceDate" length="10" /> </key-property> </composite-id> <property name="value" type="java.lang.String"> <column name="value" length="20" /> </property> 测试代码大致如下: Date tempDate = DateUtils.parseDate("2013-04-10"); TempId id = new TempId(1, tempDate); Temp temp = new Temp(id, "123"); save(temp); Temp savedTemp = load(Temp.class, id); System.out.println(savedTemp); ------预计结果------ Temp@***** ------实际结果------ null 测试代码里的save和load,都是直接使用的getHibernateTemplate()里的save和load。 日期转换DateUtils.parseDate是用的SimpleDateFormat将字符串转为日期,格式为yyyy-MM-dd。 为什么load不到结果呢?原有的数据库设计就是这样的,目前无法进行结构与类型的修改。 现在需要对这样的表进行批量新增与更新数据,这时hibernate会自动使用load方法去根据ID判断是否存在数据,如果load结果为null,就会进行插入,这时就会报错,主键唯一约束的错误。 请大家帮忙看看,有没有什么好的解决办法???

关于Hibernate级联数据表的存储问题(多对一)

本问题来自Struts2.1权威指南一书第19章例19.4问题,是一个关于Hibernate关联数据表存储的问题。 整个例子的目标就是建立一个WEB应用,在一个input.jsp页面上输入父亲和儿子信息,点击提交按钮,将这两个持久化对象的信息写入数据库中的两个数据表中,两个数据表分别是person(代表父亲)和son(代表儿子)。他们的关系是1(person)对N(son) 我在调试这个例程的时候遇到一个问题,就是在向数据库中写入持久化对象时出现错误提示如下: [color=blue]Caused by: java.sql.SQLException: Unknown column 'person_id' in 'field list'[/color] [b][color=red]经过检查具体出问题的语句是在PersonServiceImpl.java代码中的sd.save(s, son)这句(大约第在25行,就是向数据库中写入Son对象的那句)。这里说明一下sd是Son的DAO组件,具体的PersonServiceImpl.java代码见后面。 因为如果将这句注释掉,运行程序,程序可以走通,发现person表中person_id列是可以写入的。此时只是son表中没有写入任何数据。[/color][/b] 于是我检查了Person.hbm.xml、Son.hbm.xml文件,实在没有发现什么可疑之处,现将相关配置文件可能出现问题的关键部位贴出如下: --------------------PersonServiceImpl.java代码------ [code="java"] public class PersonServiceImpl implements PersonService { public void createPersonAndSon(String name , String gender , String[] sonName , int[] sonAge)throws PersonException { try { //业务逻辑组件依赖于DAO组件,从组件工厂中取出两个DAO组件 PersonDao pd = (PersonDao)ComponentFactory.instance().getComponent("personDao"); SonDao sd = (SonDao)ComponentFactory.instance().getComponent("sonDao"); //获取Hibernate Session Session s = HibernateUtil.sf.getCurrentSession(); Transaction tx = s.beginTransaction(); //以面向对象方式开始持久化操作 Person p = new Person(); p.setName(name); p.setGender(gender); pd.save(s , p); //增加Person实体关联的Son实体 for (int i = 0 ; i < sonName.length ; i++ ) { Son son = new Son(sonName[i] , sonAge[i]); son.setParent(p); sd.save(s, son);//就是这句出错了,如果注释掉这句,程序依然可以运行,只是son对象不写入数据库而已!!! } //提交事务 tx.commit(); } catch (Exception e) { e.printStackTrace(); throw new PersonException("业务异常"); } } } [/code] ---------------------Son.hbm.xml片段---------------------------------- [code="xml"] <!-- 每个class元素映射一个持久化类 --> <class name="Son" table="son"> <id name="id" column="son_id" unsaved-value="null"> <generator class="identity"/> </id> <property name="sonName" type="string"/> <property name="sonAge" type="int"/> <!-- 映射N:1关联实体 --> <many-to-one name="parent" column="person_id" class="Person" cascade="all" not-null="true"/> </class> [/code] ---------------------Person.hbm.xml片段---------------------------------- [code="xml"] <!-- 每个class元素映射一个持久化类 --> <class name="Person" table="person"> <id name="id" column="person_id" unsaved-value="null"> <generator class="identity"/> </id> <property name="name" type="string"/> <property name="gender" type="string"/> <!-- 映射1:N关联实体 --> <set name="sons" inverse="true"> <key column="person_id"/> <one-to-many class="Son"/> </set> </class> [/code] -----------------------创建数据库及表所使用的SQL语句---------------------- [code="sql"] DROP database if exists struts2hibernate; CREATE database struts2hibernate; use struts2hibernate; CREATE TABLE person(person_id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), gender VARCHAR(50)); CREATE TABLE son(son_id INT AUTO_INCREMENT PRIMARY KEY, sonName VARCHAR(50), sonAge INT); [/code] 别的文件就是光盘中提供的,基本没有修改。目前由于已经能够登录到数据库,并且可以修改部分数据内容,因此关于数据库连接方面配置应该没有问题,但是实在是不知道问题出在哪里了。请不吝赐教!不胜感激!

hibernate查询数据转换出错

create table topics( topicId int primary key AUTO_INCREMENT, userName varchar(20) not null, topicName varchar(100), context varchar(300), sendTopicTime datetime, KEY `userName` (`userName`), CONSTRAINT `FK_ID_USER` FOREIGN KEY (`userName`) REFERENCES `users` (`userName`) )ENGINE=innodb; create table Users( userId int primary key AUTO_INCREMENT, userName varchar(20) not null unique , upassWord varchar(20) not null, email varchar(20), )ENGINE=InnoDB; 映射 Users.hbm.xml: < set name="topicses" inverse="true" > < key> < column name="userName" not-null="true" /> < /key> < one-to-many class="com.wing.bean.Topics" /> < /set> Topics.hbm.xml < many-to-one name="users" class="com.wing.bean.Users" fetch="select"> < column name="userName" not-null="true" / > < / many-to-one> 2张表, hibernate映射问题工具生成的,查询topics时 报Invalid value for getInt() 错误。我估计是因为String 型的userName 做外键导致的,难道外键一定要是int型吗?求大神指教 Caused by: java.sql.SQLException: Invalid value for getInt() - 'white' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2709) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734) at org.hibernate.type.IntegerType.get(IntegerType.java:51) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173) at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:126) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2114) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1404) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332) at org.hibernate.loader.Loader.getRow(Loader.java:1230) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603) at org.hibernate.loader.Loader.doQuery(Loader.java:724) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) ... 9 more

JPA 一对多单向 映射至Mysql的问题

<p>角色Role与权限Authority,我设计成一对多单向关联,数据库mysql: <br><br>//Role.java:</p> <pre name="code" class="java">@Entity public class Role implements Serializable { private Integer roleid; private String rolename; private String description; private Set&lt;Authority&gt; auths = new HashSet&lt;Authority&gt;(); @Column public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } @Id @GeneratedValue public Integer getRoleid() { return roleid; } public void setRoleid(Integer roleid) { this.roleid = roleid; } @Column public String getRolename() { return rolename; } public void setRolename(String rolename) { this.rolename = rolename; } <span style="color: #ff0000;">//一对多单向关联</span> <span style="color: #0000ff;">@OneToMany(cascade = CascadeType.REFRESH, fetch=FetchType.EAGER) @JoinTable(name = "role_auth", joinColumns = @JoinColumn(name = "roleid"), inverseJoinColumns = @JoinColumn(name = "authorityid")) public Set&lt;Authority&gt; getAuths() { return auths; } public void setAuths(Set&lt;Authority&gt; auths) { this.auths = auths; }</span> // 添加权限 public void addAuth(Authority auth) { this.auths.add(auth); } @Override public int hashCode() { ... } @Override public boolean equals(Object obj) { ... } } </pre> <p><br><br>//Authority.java:</p> <pre name="code" class="java">@Entity public class Authority implements Serializable { private Integer authorityid; // 范围 private Range range; // 动作 private Action action; public Authority() {} public Authority(Range range, Action action) { this.range = range; this.action = action; } @ManyToOne @JoinColumn(name="actionid", referencedColumnName="actionid") public Action getAction() { return action; } public void setAction(Action action) { this.action = action; } @Id @GeneratedValue public Integer getAuthorityid() { return authorityid; } public void setAuthorityid(Integer authorityid) { this.authorityid = authorityid; } @ManyToOne @JoinColumn(name="rangeid", referencedColumnName="rangeid") public Range getRange() { return range; } public void setRange(Range range) { this.range = range; } @Override public int hashCode() { ... } @Override public boolean equals(Object obj) { ... } } </pre> <p><br><br>生成的中间表为role_auth,查看建表语句:</p> <pre name="code" class="sql">mysql&gt; show create table user_role; | Table | Create Table | user_role | CREATE TABLE `user_role` ( `userid` int(11) NOT NULL, `roleid` int(11) NOT NULL, PRIMARY KEY (`userid`,`roleid`), <span style="color: #ff0000;">UNIQUE KEY `roleid` (`roleid`),//roleid为什么具有唯一性???</span> KEY `FK143BF46A889EC6EB` (`userid`), KEY `FK143BF46A83497181` (`roleid`), CONSTRAINT `FK143BF46A83497181` FOREIGN KEY (`roleid`) REFERENCES `role` (`rol eid`), CONSTRAINT `FK143BF46A889EC6EB` FOREIGN KEY (`userid`) REFERENCES `user` (`use rid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | 1 row in set (0.00 sec) </pre> <p><br><br>如上红色部分,roleid具有唯一性,这样我在插入角色时就会出现类似“Duplicate entry '2' for key 2”的错误。 <br>该怎么改呢??</p> <p> </p>

SSH整合,hibernate注解配置,无hbm.xml,映射出现问题

java实体类代码: ``` package cn.com.car.base.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="T_CAR") public class Car implements Serializable{ private static final long serialVersionUID = 1L; @GenericGenerator(name = "generator", strategy = "guid") @Id @GeneratedValue(generator = "generator") @Column(name = "id", unique = true, nullable = false, length = 38) private String id; @Column(name="models") private String models;//具体车型 @Column(name="type") private String type;//所属类别 @Column(name="price") private int price;//价格 public String getId() { return id; } public void setId(String id) { this.id = id; } public String getModels() { return models; } public void setModels(String models) { this.models = models; } public String getType() { return type; } public void setType(String type) { this.type = type; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } @Override public String toString() { return "Car [id=" + id + ", models=" + models + ", type=" + type + ", price=" + price + "]"; } } ``` ------------------------------------------ application.xml配置 ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" default-autowire="byName" default-lazy-init="true"> <!-- 属性文件读入 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:hibernate.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${hibernate.connection.driverClassName}"/> <property name="url" value="${hibernate.connection.url}"/> <property name="username" value="${hibernate.connection.username}"/> <property name="password" value="${hibernate.connection.password}"/> </bean> <!--Hibernate SessionFatory--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="annotatedClasses"> <list> <value>cn.com.car.base.entity.Car</value> </list> </property> <property name="hibernateProperties"> <value>classpath:hibernate.properties</value> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> </beans> ``` ---------------------------------------- hibernate.properties配置文件 ``` hibernate.show_sql=true hibernate.format_sql=false hibernate.cache=org.hibernate.cache.EhCacheProvider hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.connection.driverClassName=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost:3306/car hibernate.connection.username=car hibernate.connection.password=123456 hibernate.c3p0.minPoolSize=5 hibernate.c3p0.maxPoolSize=50 hibernate.c3p0.timeout=1800 hibernate.c3p0.max_statement=200 ``` ---------------------------------- DAO层 ``` package cn.com.car.base.dao.impl; import java.util.HashMap; import java.util.List; import org.hibernate.Query; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import cn.com.car.base.dao.CarDao; import cn.com.car.base.entity.Car; public class CarDaoImpl extends HibernateDaoSupport implements CarDao { @Override public List<Car> getAllCar() { String sql="from T_CAR where 1=1"; List<Car> list=this.getHibernateTemplate().find(sql); return list; } @Override public List<Car> getCarByParam(HashMap<String, String> param) { StringBuilder sql=new StringBuilder(); sql.append("select * from T_CAR where 1=1"); if(param!=null){ if(param.get("type")!=null){ String type=param.get("type"); sql.append("and type="+type); } if(param.get("price")!=null){ String price=param.get("price"); sql.append("and price="+price); } Query query = this.getSession().createSQLQuery(sql.toString()); List<Car> list=query.list(); return list; } List<Car> list=this.getHibernateTemplate().find(sql.toString()); return list; } @Override public Car getCarByModels(String models) { String hql = "from T_CAR t where 1=1 " +" and t.models=? "; Query query = this.getSession().createQuery(hql).setString(0, models); return (Car) query.list().get(0); } @Override public Car getCarById(String id) { String hql = "from T_CAR t where 1=1 " +" and t.id=? "; Query query = this.getSession().createQuery(hql).setString(0, id); return (Car) query.list().get(0); } } ``` 我是模仿别的项目搭建的,没有.hbm.xml,现在运行DAO层就出现 “org.hibernate.hql.ast.QuerySyntaxException: T_CAR is not mapped [from T_CAR where 1=1]”这样的错误。

新手求解一个hibernate3.6.10的问题

先贴代码: User类: public class User { private Integer id; private String nickName; private String password; private String familyName; private String name; private String fullName; private Boolean gender; private String nameStyle; private Date registerDate; private Date lastLoginDate; // getters和setters省略 } User.hbm.xml映射文件: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="org.maxwell.app.domain"> <class name="User" table="users" lazy="true"> <id name="id" column="user_id" length="11" type="int" > <generator class="identity" /> </id> <property name="nickName" column="nick_name" length="20" unique="true" not-null="true" /> <property name="password" length="20" not-null="true" /> <property name="familyName" column="family_name" length="20" /> <property name="name" length="20" /> <property name="gender" type="java.lang.Boolean" /> <property name="nameStyle" column="name_style" type="string" length="1" /> <property name="registerDate" type="timestamp" column="register_date" /> <property name="lastLoginDate" type="timestamp" column="last_login_date" /> <property name="fullName" formula="( select concat(u.family_name, u.name) from users u where u.user_id= id)" /> </class> </hibernate-mapping> 测试类: public class TestNews { public static void main(String[] args) { Configuration config = new Configuration().configure(); SessionFactory sf = config.buildSessionFactory(); Session session = sf.openSession(); Transaction tx = session.beginTransaction(); User u = new User().setNickName("Maxwell").setPassword("1234") .setFamilyName("张").setName("飞扬").setNameStyle("E") .setRegisterDate(new Date()).setLastLoginDate(new Date()); session.save(u); System.out.println(u); User u2 = (User) session.load(User.class, new Integer(1)); System.out.println(u2); tx.commit(); session.close(); sf.close(); } } 请问为什么会报出下面这样的错误呢? Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not load an entity: [org.maxwell.app.domain.User#1] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.loadEntity(Loader.java:2041) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3294) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:147) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1026) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) at org.maxwell.app.domain.User_$$_javassist_0.getFullName(User_$$_javassist_0.java) at org.maxwell.app.domain.TestNews.main(TestNews.java:25) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'user0_.id' in 'where clause' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2818) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2157) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2324) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1953) at org.hibernate.loader.Loader.doQuery(Loader.java:802) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) at org.hibernate.loader.Loader.loadEntity(Loader.java:2037) ... 14 more

hibernate中报SessionFactory为空

这是我的hibernate.cfg.xml文件的内容 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 配置连接数据库 --> <property name="connection.username">root</property> <property name="connection.password">195824</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">idbc:mysql:///testHibernateTable<!-- ?useUnicode=true&amp;characterEncoding:UTF-8 --></property> <property name="javax.persistence.validation.mode">none</property> <!-- 数据库操作语句的显示 --> <property name="show_sql">true</property> <!-- 将数据库的输出是否排版 --> <property name="format_sql">true</property> <!-- 数据表的生成策略 有四个create:传建一个新的数据表,若存在则删除存在的在创建一个新的; update:更新原有表; creat_drop:先创建再删除; validate:对原来的表结构进行验证,若不同创建一个新的表--> <property name="hbm2ddl.auto">create</property> <!-- 数据表的方言 --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <mapping resource="com/test/hibernate/Student.hbm.xml"/> </session-factory> </hibernate-configuration> 这是我映射的Student.hbm.xml文件的内容 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- Generated 2017-7-17 23:09:26 by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="com.test.Hibernate.Student" table="STUDENT"> <id name="id" type="int"> <column name="ID" /> <generator class="assigned" /> </id> <property name="name" type="java.lang.String"> <column name="NAME" /> </property> <property name="sex" type="java.lang.String"> <column name="SEX" /> </property> <property name="age" type="int"> <column name="AGE" /> </property> </class> </hibernate-mapping> 这是我测试类的内容 package com.test.Junit; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.test.hibernate.Student; public class TestHiber { /** * 获得关系映射对象文件 */ private SessionFactory sessionFactory=null; /** *类似于JDBC中的Connection */ private Session session; /** * 获得事物对象 */ private Transaction transaction; private Configuration config; @Before public void init(){ //读取配置文档hibernate.cfg.xml文件 config = new Configuration().configure("hibernate.cfg.xml"); //创建服务注册对象 ServiceRegistry serviceRegistry = new ServiceRegistryBuilder(). applySettings(config.getProperties()).buildServiceRegistry(); //创建会话工厂对象 sessionFactory = config.buildSessionFactory(serviceRegistry); //会话对象 session = sessionFactory.getCurrentSession(); //打开事物 transaction = session.beginTransaction(); } @After public void destory(){ transaction.commit();//提交事务 session.close();//关闭会话 sessionFactory.close();//关闭会话工厂对象 } @Test public void test() { Student student = new Student(1, "Minions", "sex", 10); session.save(student); } } 这是junit报错的内容 java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator could not be instantiated at java.util.ServiceLoader.fail(ServiceLoader.java:232) at java.util.ServiceLoader.access$100(ServiceLoader.java:185) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:233) at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:53) at org.hibernate.service.internal.BootstrapServiceRegistryImpl.<init>(BootstrapServiceRegistryImpl.java:80) at org.hibernate.service.internal.BootstrapServiceRegistryImpl.<init>(BootstrapServiceRegistryImpl.java:57) at org.hibernate.service.ServiceRegistryBuilder.<init>(ServiceRegistryBuilder.java:76) at com.test.Junit.TestHiber.init(TestHiber.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/index/CorruptIndexException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214) at org.hibernate.search.util.logging.impl.LoggerFactory.make(LoggerFactory.java:37) at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.<clinit>(HibernateSearchIntegrator.java:49) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at java.lang.Class.newInstance(Class.java:442) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) ... 32 more Caused by: java.lang.ClassNotFoundException: org.apache.lucene.index.CorruptIndexException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 44 more java.lang.NullPointerException at com.test.Junit.TestHiber.destory(TestHiber.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 以下是控制台的报错内容 INFO: HHH000221: Reading mappings from resource: com/test/hibernate/Student.hbm.xml 七月 19, 2017 10:29:01 下午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null

hibernate 日志异常

最近学习hibernate,看书感觉可以,实际操作怎么就那么难呢! 我用的是:hibernate3.2 eclipse3.3 (没有Myeclipse插件) Mysql6.0 一:main()函数 package org.first; import org.hibernate.*; import org.hibernate.cfg.*; public abstract class FirstM { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Configuration conf=new Configuration().configure(); SessionFactory sf=conf.buildSessionFactory(); Session sess=sf.openSession(); Transaction tx=sess.beginTransaction(); FirstBean fb=new FirstBean(); fb.setUserId(12); fb.setUserName("thmei123"); sess.save(fb); tx.commit(); sess.close(); } } 二:持久化类:很简单,一个主键userId,和一个属性userName; public class FirstBean { private int userId; private String userName; public void setUserId(int userId) { this.userId=userId; } public int getUserid() { return this.userId; } public void setUserName(String userName) { this.userName=userName; } public String getUserName() { return this.userName; } } 三:影射文件和配置文件: 1:<?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 name="FirstBean" table="student"> <id name="userId" unsaved-value="null"> <generator class="identity"/> </id> <property name="userName"/> </class> </hibernate-mapping> 2: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property> <property name="hibernate.connection.password">thmei123</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/user</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.min_size">1</property> <property name="hibernate.c3p0.timeout">5000</property> <property name="hibernate.c3p0.max_statements">100</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <property name="hibernate.c3p0.validate">true</property> <mapping resource="hib.hbm.xml"> </session-factory> </hibernate-configuration> 说明;在主函数main()中运行后提示: Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException at org.first.FirstM.main(FirstM.java:12) Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) 提示的是要文件: log4j-1.2.11.jar 和commons-logging-1.0.4.jar 这两个jar文件我都拷贝到了SRC下面了,也不可以阿 在网上查询说的是好像main()函数中不可以用日志文件, 希望大家帮我了, 另外 请大家给我一个详细的例子吧,最好是web工程的和java工程 各一个例子, 同时天涯沦落人啊!! [b]问题补充:[/b] 谢谢 楼上兄弟的给你资料和建议,我现在除了拷贝了log4j-1.2.11.jar 和commons-logging-1.0.4.jar 这两个文件外,还在hibernate下拷贝了一个log4j.property的属性文件,都放置到了src下面,但是现在又出下面错误: 22:11:54,599 INFO Environment:514 - Hibernate 3.2.6 22:11:54,619 INFO Environment:547 - hibernate.properties not found 22:11:54,629 INFO Environment:681 - Bytecode provider name : cglib 22:11:54,639 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling 22:11:54,850 INFO Configuration:1432 - configuring from resource: /hibernate.cfg.xml 22:11:54,850 INFO Configuration:1409 - Configuration resource: /hibernate.cfg.xml 22:11:55,501 INFO Configuration:559 - Reading mappings from resource : hib.hbm.xml 22:11:56,212 INFO HbmBinder:300 - Mapping class: FirstBean -> student org.hibernate.InvalidMappingException: Could not parse mapping document from resource hib.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:575) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593) 其中: 一:22:11:54,619 INFO Environment:547 - hibernate.properties not found 提示没有找到hibernate.properties 是怎么会事?我已经放置hibernate.properties,这个文件不是自己写,因为我不会写,就在hibernate下拷贝的一个,请大家给出建议,谢谢 二:org.hibernate.InvalidMappingException: Could not parse mapping document from resource hib.hbm.xml 这个实际上是提示没有找到hib.hbm.xml映射文件,我很是奇怪,无论我怎么修改<mapping resource="hib.hbm.xml">的映射路径,都是不可以的!请大家帮助!! 学习中,望大家指点 谢谢

hibernate 中的load方法出现异常 不想关闭懒加载还有什么方法可以解决这个异常

// 1.创建一个SessionFactory对象 SessionFactory sessionFactory = null; // 2.创建session对象 Session session = null; @Before public void init() { // 3.把注册信息传入ServiceRegistry接口中 Hibernate5.X做法 StandardServiceRegistry registry = new StandardServiceRegistryBuilder() .configure().build(); try { // 4.获取sessionFactory sessionFactory = new MetadataSources(registry).buildMetadata() .buildSessionFactory(); } catch (Exception e) { // 出现异常需要销毁StandardServiceRegistry注册表 StandardServiceRegistryBuilder.destroy(registry); } // 5.获取session对象 session = sessionFactory.openSession(); // 6.开启事务 session.beginTransaction(); } @Test public void testGet() { // 加载 使用get User u =session.get(User.class,1); System.out.println(u.getClass()); } @Test public void testLoad() { User u =session.load(User.class,2); System.out.println(u.getClass()); } @After public void close() { // 8.提交事务 session.getTransaction().commit(); // 9.释放所有资源 session.close(); sessionFactory.close(); } 控制台是: java.lang.ClassCastException: com.ltt.user.User_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy 2018-5-24 20:05:25 org.hibernate.event.internal.DefaultLoadEventListener doOnLoad INFO: HHH000327: Error performing load command : org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: com.ltt.user.User 2018-5-24 20:05:25 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql:///test0221] Junit界面是:org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: com.ltt.user.User 我就是想问如果不在映射文件中设置class标签中的lazy属性为false怎么才能消除异常 设置为lazy=false之后那load和get方法不是一样了吗?都变成了立即搜索

hibernate中单向多对一的关联疑惑(管理员勿将帖子转到问答,那里不好交流)

本人初学hibernate,希望大家多多指教! <br />我假设person和card的多对一的关系(实际这两者的关系不是多对一) <br />他们对应的映射文件是: <br /><strong>person.hbm.xml</strong> <br /><pre name="code" class="xml"><!----> &lt;hibernate-mapping schema="hibernatequickuse"&gt; &lt;class name="mypack.person" table="person"&gt; &lt;id name="id" column="id" type="java.lang.Integer"&gt; &lt;generator class="identity"&gt; &lt;/id&gt; &lt;property name="name" column="name" type="java.lang.String" not-null="true"&gt;&lt;/property&gt; &lt;many-to-one name="mycard" column="card_id" class="mypack.Card" cascade="all"&gt;&lt;/many-to-one&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </pre> <br /><strong>Card.hbm.xml</strong> <br /><pre name="code" class="xml"><!----> &lt;hibernate-mapping&gt; &lt;class name="mypack.Card" table="card"&gt; &lt;id name="id" column="ID" type="java.lang.Integer"&gt; &lt;generator class="identity"&gt; &lt;/id&gt; &lt;property name="name" column="NAME" type="java.lang.String" not-null="true"&gt;&lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </pre> <br />假设当我们先把many-to-one中的cascade属性值去掉,改为: <br /><pre name="code" class="xml">&lt;many-to-one name="mycard" column="card_id" class="mypack.Card"&gt;&lt;/many-to-one&gt; </pre> <br />然后执行如下代码: <br /><pre name="code" class="java"> person p=new person(); p.setName("jack01"); Card c=new Card(); c.setName("card0031"); p.setMycard(c); Session session=null; Transaction tran=null; try{ session=factory.openSession(); tran=session.beginTransaction(); session.save(p);//为什么是update,而不是Insert tran.commit(); 。。。。。。。 </pre> <br />执行结果本来应该会报一个异常,因为只持久化了person对象。而card是临时对象,所以当hibernate自动清理缓存中的持久化对象时会发现p引用了c临时对象,而在person表中对应的card_id字段值为0,这说明person持久化对象的状态和数据库的记录不一致,所以应该会抛出异常!但是它却并没有抛出异常, <br />而是插入了一条person记录,其card_id=0这是为什么??? <br /><pre name="code" class="sql">Hibernate: insert into hibernatequickuse.person (name, card_id) values (?, ?)</pre> <br />当我把cascade="all"加上去之后,本来这时应该是先插入card记录,然后插入Person记录。但结果却是: <br /><pre name="code" class="sql">Hibernate: insert into hibernatequickuse.person (name, card_id) values (?, ?) Hibernate: update card set NAME=? where ID=? </pre> <br />而且抛出异常,表示无法更新!这又是为什么???????? <br /><pre name="code" class="java">Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 </pre> <br /><strong>表结构如下:</strong> <br /><pre name="code" class="sql">-- -- 表的结构 `card` -- CREATE TABLE `card` ( `id` int(11) NOT NULL auto_increment, `name` varchar(20) collate latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=7 ; CREATE TABLE `person` ( `id` int(11) NOT NULL auto_increment, `name` varchar(32) collate latin1_general_ci NOT NULL, `card_id` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `card_id` (`card_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ; </pre> <br /><strong>POJO如下:</strong> <br /><strong>person</strong> <br /><pre name="code" class="java">package mypack; public class person implements java.io.Serializable{ private int id; private String name; private Card mycard; public person(){ } private void setId(int id){ this.id=id; } public void setName(String name){ this.name=name; } public void setMycard(Card mycard){ this.mycard=mycard; } public int getId(){ return this.id; } public String getName(){ return this.name; } public Card getMycard(){ return this.mycard; } } </pre> <br /> <br /><strong>Card</strong> <br /><pre name="code" class="java">package mypack; public class Card { private int id; private String name; public Card(){ } public void setId(int id){ this.id=id; } public void setName(String name){ this.name=name; } public String getName(){ return this.name; } public int getId(){ return this.id; } } </pre> <br /> <br /><br /><strong>问题补充</strong><br />补充下:我是参照网友的教程来做的,地址是:http://ryanpoy.iteye.com/blog/189783 <br />奇怪的是他的结果是正确的!程序里面唯一不同的是我主键的设置上,我用的是auto_increment,映射xml中用的是identity! <br /> <br /><br /><strong>问题补充:</strong><br />谢谢kulinglei的回答,问题是我将cascade="save-update"; 它也没报任何异常啊,正常的情况应该是会报你所说的异常啊 !我把源码上传下,能帮我看看吗?<br /><strong>问题补充:</strong><br />这是源码,希望大家帮帮忙!<br /><strong>问题补充:</strong><br />谢谢etank帮忙,但我也用的是hibernate3的包,并且把identity改为了native。把cascade设为none,结果还是没报任何异常啊?我用的是mysql的数据库

JDBC version [3] less than 4的异常

报错在这里 INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 Exception in thread "main" java.lang.NullPointerException at hibernateJava_1.Test.test(Test.java:30) at hibernateJava_1.Test.main(Test.java:39) 代码是这个 package hibernateJava_1; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class Test { public static void test(){ //价值hibernate核心配置文件 Configuration cfg=new Configuration(); cfg.configure(); //创建session工厂对象 SessionFactory factory=null; Session session=null; Transaction tx=null; try{ factory=cfg.buildSessionFactory(); //创建session session=factory.openSession(); //开始实务 tx=session.beginTransaction(); //crud session.save(new User(1,"zhangSan",23,"captain")); //结束事务 tx.commit(); }catch(Exception e){ tx.rollback(); e.printStackTrace(); }finally{ if(session!=null)session.close(); if(factory!=null)factory.close(); } } public static void main(String[] args) { test(); } } 这里是映射xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="hibernageJava_1.user" table="t_user"> <id name="uid" column="uid"> <generator class="native"></generator> </id> <property name="username" column="username"></property> <property name="age" column="age"></property> <property name="address" column="address"></property> </class> </hibernate-mapping> 这里是核心hibernate.fig.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 四大参数 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:///student</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123</property> <!-- 在控制台显示sql --> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <!-- 自动建表 --> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 识别方言 --> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 映射那个user映射xml文件 --> <mapping resource="hibernateJava_1/User.mapping.xml"/> </session-factory> </hibernate-configuration> 映射实体类应该也没有什么错啊 package hibernateJava_1; public class User { private int uid; private String username; private int age; private String address;

getHibernateTemplate()为NUll,困扰好几天了,网上也找了好些方法一直解决不掉

小弟刚刚开始学SSH,是用的Struts2+Hibernate+Spring,运行的时候发现getHibernateTemplate()得到的模板类始终是nUll值,郁闷好几天了,一直在我网上试各种方法,迄今任为解决,恳请各位指教咯! [size=large][b]applicationContext.xml:([/b]事务处理这儿没贴出来)[/size] [code="java"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- 定义数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/jjufriend"></property> <property name="username" value="root"></property> <property name="password" value="root"></property> </bean> <!-- 定义Hibernate的sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <!-- Hibernate 的sessionFactory的属性 --> <property name="hibernateProperties"> <props> <!-- 数据库方言 --> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> <!-- 显示Hibernate持久化操作所生成的SQL语句 --> <prop key="hibernate.show_sql">true</prop> <!-- 将SQL脚本进行格式化后再输出 --> <prop key="hibernate.format_sql">true</prop> </props> </property> <!-- 列出全部的映射文件 --> <property name="mappingResources"> <list> <value>com/jjufriend/student/model/Student.hbm.xml</value></list> </property></bean> <!-- 配置dao组件 --> <bean id="studentDao" class="com.jjufriend.student.dao.impl.StudentDaoHibernate"> <!-- 依赖注入DAO组件所必需的SessionFactory引用 --> <property name="sessionFactory" ref="sessionFactory"> </property> </bean> <!-- 配置业务逻辑组件 --> <bean id="mgr" class="com.jjufriend.student.service.impl.StudentManagerImpl"> <property name="studentDao" ref="studentDao"></property> </bean> [/code] [size=large]studentDao.java:[/size] [code="java"]package com.jjufriend.student.dao; import java.util.List; import com.jjufriend.student.model.Student; public interface StudentDao { Student get(Integer id); Integer save(Student student); void update(Student student); void delete(Student student); void delete(Integer id); List<Student> findAll(); Student findStudentByNameAndPass(String username,String password); Student findByName(String username); }[/code] [size=large]StudentDaoHibernate.java:[/size] [code="java"]package com.jjufriend.student.dao.impl; import java.io.Serializable; import java.util.List; import org.hibernate.SessionFactory; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.jjufriend.student.dao.StudentDao; import com.jjufriend.student.model.Student; public class StudentDaoHibernate extends HibernateDaoSupport implements StudentDao,Serializable { private SessionFactory sessionFactory; HibernateTemplate ht = this.getHibernateTemplate() ; public void delete(Student student) { // TODO Auto-generated method stub getHibernateTemplate().delete(student); } public void delete(Integer id) { // TODO Auto-generated method stub getHibernateTemplate().delete(get(id)); } public List<Student> findAll() { // TODO Auto-generated method stub return (List<Student>)getHibernateTemplate().find("from Student"); } public Student findByName(String username) { List stu = getHibernateTemplate().find("from Student st where st.username = ?",username); if(stu != null && stu.size() >= 1){ return (Student)stu.get(0); } return null; } public Student findStudentByNameAndPass(String username, String password) { // TODO Auto-generated method stub List students = null; try{ // HibernateTemplate temple = this.getHibernateTemplate(); System.out.println("模板类是否为NULL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ht); // 取出所有 students = temple.find("from student"); students = ht.find("from student st where st.username = " + username + " and st.password = " + password); }catch(Exception e){ System.out.println("查找过程中出现异常.............."); e.printStackTrace(); } if(students != null && students.size() >= 1){ return (Student)students.get(0); } return null; } public Student get(Integer id) { return (Student)getHibernateTemplate().get(Student.class, id); } public Integer save(Student student) { return (Integer)getHibernateTemplate().save(student); } public void update(Student student) { // TODO Auto-generated method stub getHibernateTemplate().update(student); } } [/code] [size=large]StudentManager.java:[/size] [code="java"]package com.jjufriend.student.service; import com.jjufriend.student.model.Student; public interface StudentManager { int addStudent(Student student) throws Exception; int loginValid(Student student) throws Exception; boolean validateName(String username) throws Exception; } [/code] [size=large]StudentManagerImpl.java:[/size] [code="java"]package com.jjufriend.student.service.impl; import com.jjufriend.student.dao.StudentDao; import com.jjufriend.student.dao.impl.StudentDaoHibernate; import com.jjufriend.student.model.Student; import com.jjufriend.student.service.StudentManager; public class StudentManagerImpl implements StudentManager { /*2009-11-12 22:44修改 出去new StudentDaoHibernate() */ private StudentDao studentDao = new StudentDaoHibernate() ; // private ApplicationContext cxt = // new FileSystemXmlApplicationContext("../webapps/JJUFriend/WEB-INF/applicationContext.xml"); // studentDao =(StudentDaoHibernate)cxt.getBean("studentDao"); public void setStudentDao(StudentDao studentDao){ this.studentDao = studentDao ; } public int addStudent(Student student) throws Exception { // TODO Auto-generated method stub try{ studentDao.save(student); return student.getId(); }catch(Exception e){ e.printStackTrace(); throw new Exception("新增用户时出现异常"); } } public int loginValid(Student student) throws Exception { try{ System.out.println(studentDao); System.out.println("是否取到页面提交的数据:Name="+student.getUsername()); Student stu = studentDao.findStudentByNameAndPass(student.getUsername(), student.getPassword()); if(stu != null ){ return stu.getId(); } }catch(Exception e){ System.out.println("验证用户登录时出现异常"); e.printStackTrace(); } // TODO Auto-generated method stub return -1; } public boolean validateName(String username) throws Exception { // TODO Auto-generated method stub try{ if (studentDao.findByName(username) != null){ return true ; } }catch(Exception e){ System.out.println("验证用户名是否用效时出错"); e.printStackTrace(); } return false ; } } [/code] 问题的关键是通过方法getHibernateTemplate()不能正确得到HibernateTemplate对象,始终的空值,网上有很多解决的办法,差不多我都试过了, 下面这种方法是说不能直接new StudentDao对象,用下面这种方法取得,可以启动服务器老是不停地跳动,一直不停,直到报错。 [code="java"] // private ApplicationContext cxt = // new FileSystemXmlApplicationContext("../webapps/JJUFriend/WEB-INF/applicationContext.xml"); // private StudentDao studentDao =(StudentDaoHibernate)cxt.getBean("studentDao");[/code] 还有些方法是直接从applicationContext.xml中的bean取得HibernateTemplate对象,始终都搞不定,望大家指教了。 [size=medium](顶格的System.out.println()语句均是测试用的语句)[/size] [b]问题补充:[/b] 谢谢大家的热心帮助!! 确实其中出了不少问题,主要是最近网上看到解决这个方法的帖子很多,尝试过很多方法,都有点儿改晕了。 一楼的方法我尝试了,还是不行,[code="java"] private ApplicationContext cxt = this.getApplicationContext(); private StudentDao studentDao = (StudentDaoHibernate)cxt.getBean("studentDao"); [/code] 其中那个this.getApplicationContext(); 方法根本不存在啊,无法取得配置文件。 之前类似的方法我也用过就是用[code="java"] private ApplicationContext cxt = new FileSystemXmlApplicationContext("../webapps/JJUFriend/WEB-INF/applicationContext.xml"); private StudentDao studentDao =(StudentDaoHibernate)cxt.getBean("studentDao"); [/code]取得,但是当启动服务器后,后台一直跑个不停,仿佛是个死循环似的。浏览器中通过http://localhost:8080访问都无效! StudentDaoHibernate.java中的private SessionFactory sessionFactory;已经去掉 数据库方言也该过来了

一条HQL语句引起的异常

表结构: CREATE TABLE IF NOT EXISTS tb_cases( id int(11) NOT NULL auto_increment, cdate date default NULL, title varchar(50) default NULL, cont text, imgpath varchar(80) default NULL, apply text, PRIMARY KEY (id) )ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; Hibernate映射文件: <?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 name="com.base.hibernate.po.Cases" table="tb_cases"> <id name="id" type="java.lang.Integer"> <column name="id" /> <generator class="native" /> </id> <property name="cdate" type="java.util.Date"> <column name="cdate" length="10" /> </property> <property name="title" type="java.lang.String"> <column name="title" length="50" /> </property> <property name="content" type="java.lang.String"> <column name="cont" /> </property> <property name="imgpath" type="java.lang.String"> <column name="imgpath" length="50" /> </property> <property name="apply" type="java.lang.String"> <column name="apply" /> </property> </class> </hibernate-mapping> HQL语句: String FIND_CASENUM = " from Cases order by cdate desc "; 实现方法: public List<Cases> getCasesNum(final int showPage, final int pageSize){ return getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(final Session session) { Query query = session.createQuery(FIND_CASENUM); query.setFirstResult((showPage - 1) * pageSize); query.setMaxResults(pageSize); List<Cases> casesList = query.list(); if(null == casesList || casesList.isEmpty()){ casesList = null; } return casesList; } }); } 抛出异常: Hibernate: select top 4 cases0_.id as id1_, cases0_.cdate as cdate1_, cases0_.title as title1_, cases0_.cont as cont1_, cases0_.imgpath as imgpath1_, cases0_.apply as apply1_ from tb_cases cases0_ order by cases0_.cdate desc 2009-07-08 13:06:22,281 [org.hibernate.util.JDBCExceptionReporter]-[WARN] SQL Error: 1064, SQLState: 42000 2009-07-08 13:06:22,281 [org.hibernate.util.JDBCExceptionReporter]-[ERROR] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4 cases0_.id as id1_, cases0_.cdate as cdate1_, cases0_.title as title1_, cases0' at line 1 2009-07-08 13:06:26,812 [org.apache.struts.action.RequestProcessor]-[WARN] Unhandled Exception thrown: class org.springframework.dao.InvalidDataAccessResourceUsageException 2009-07-08 13:06:26,812 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/bianyaqi].[action]]-[ERROR] Servlet.service() for servlet action threw exception org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2223) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at com.base.hibernate.dao.impl.CasesDaoImpl$1.doInHibernate(CasesDaoImpl.java:65) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:342) at com.base.hibernate.dao.impl.CasesDaoImpl.getCasesNum(CasesDaoImpl.java:60) at com.base.spring.service.impl.CasesServiceImpl.getCasesNum(CasesServiceImpl.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy1.getCasesNum(Unknown Source) at com.base.struts.action.IndexAction.execute(IndexAction.java:130) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.base.common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:123) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at com.base.common.filter.ForceNoCacheFilter.doFilter(ForceNoCacheFilter.java:36) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:619) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4 cases0_.id as id1_, cases0_.cdate as cdate1_, cases0_.title as title1_, cases0' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) at org.hibernate.loader.Loader.getResultSet(Loader.java:1787) at org.hibernate.loader.Loader.doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2220) ... 54 more 怀疑是HQL语句有什么错误,但愣是没找出来 映射文件与表中的字段名也检查过了,没什么问题啊! 查看了好久也没找出到底什么地方的错误 还请各们朋友们帮下忙看下到底怎么回事! 补充: 如果将HQL语句改成 from Product 问题依旧 但在Mysql数据库中使用 select id,cdate,title,cont,imgpath,apply from tb_cases; 语句没有任何错误!

java.sql.SQLException: Column 'gp_id' not found.

在hibernate中调用存储过程,其中我的存储过程编写如下: [code="java"] DELIMITER $$ DROP PROCEDURE IF EXISTS `qdrk`.`undobusiness`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `undobusiness`() BEGIN DECLARE business_date timestamp default current_timestamp; DECLARE mon int; SELECT business_date; SELECT max(plandate) into business_date from jz_business_plan; SELECT business_date; set mon = DATE_FORMAT(business_date,'%m'); WHILE (mon < DATE_FORMAT(Now(),'%m')) do insert into jz_business_plan(g_id,gb_id,account_id,bs_id) values(g_id,gb_id,account_id,bs_id); select g_id ,gb_id,account_id,bs_id from jz_gbmes where ((stday < date_format(Now(),'%d') and enday > date_format(Now(),'%d') and remindtype= '2') ; set mon = mon+1; end WHILE; SELECT * from jz_business_plan WHERE DATE_FORMAT(jz_business_plan.plandate,'%m') = DATE_FORMAT(now(),'%m'); END$$ DELIMITER ; [/code] hibernate的配置文件如下: [code="java"] hibernate-mapping> <class name="cn.qdrk.strive.model.JzBusinessPlan" table="jz_business_plan" catalog="qdrk"> <id name="gpId" type="java.lang.Integer"> <column name="gp_id" /> <generator class="native"></generator> </id> <many-to-one name="accountTable" class="cn.qdrk.strive.model.AccountTable" fetch="select"> <column name="account_id" /> </many-to-one> <many-to-one name="jzBusiness" class="cn.qdrk.strive.model.JzBusiness" fetch="select"> <column name="bs_id" /> </many-to-one> <many-to-one name="jzGuestbook" class="cn.qdrk.strive.model.JzGuestbook" fetch="select"> <column name="gb_id" /> </many-to-one> <many-to-one name="jzGbmes" class="cn.qdrk.strive.model.JzGbmes" fetch="select"> <column name="g_id" /> </many-to-one> <property name="plandate" type="java.util.Date"> <column name="plandate" length="19" not-null="true" /> </property> <property name="remark" type="java.lang.String"> <column name="remark" /> </property> </class> <sql-query name="undobusiness" callable="true"> <return alias="JzBusinessPlan" class="cn.qdrk.strive.model.JzBusinessPlan"> <return-property name="gp_id" column="gp_id"/> <return-property name="g_id" column="g_id" /> <return-property name="account_id" column="account_id"/> <return-property name="bs_id" column="bs_id" /> <return-property name="plandate" column="plandate" /> <return-property name="remark" column="remark" /> <return-property name="gb_id" column="gb_id" /> </return> {call undobusiness()} </sql-query> </hibernate-mapping> [/code] 错误信息如下: [code="java"] 2008-11-13 09:38:07,882 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: S0022 2008-11-13 09:38:07,882 ERROR [org.hibernate.util.JDBCExceptionReporter] - Column 'gp_id' not found. org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2148) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164) at cn.qdrk.strive.dao.hibernate.CRMDaoHibernate.undoBusiness(CRMDaoHibernate.java:43) at cn.qdrk.strive.dao.hibernate.CRMDaoHibernate$$FastClassByCGLIB$$afe1117e.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) [/code] [code="java"] Caused by: java.sql.SQLException: Column 'gp_id' not found. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1093) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2734) at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:237) at org.hibernate.type.IntegerType.get(IntegerType.java:28) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102) at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1088) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:554) at org.hibernate.loader.Loader.doQuery(Loader.java:689) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2145) [/code] [b]问题补充:[/b] 我的jz_business_plan表中有这个键值的映射啊,至于二楼说的return-property name="gp_id" column="gp_id"/> 你的属性名不是gpId吗,改成gpId一样也会出现这样的问题。 [b]问题补充:[/b] [color=red]我调用存储过程call undobusiness();除了gp_id为4,plandate为当前时间,其他的列值都是null,难道是这方面的原因,哪么调用存储过程select g_id ,gb_id,account_id,bs_id from jz_gbmes where ((stday < date_format(Now(),'%d') and enday > date_format(Now(),'%d') and remindtype= '2') ;会列出数据,这样怎么修改呢?[/color] [b]问题补充:[/b] [color=red]E文没看懂,如果返回的是null,该怎么修改呢?万分感谢![/color] [b]问题补充:[/b] name属性是用来关联column的,我不用程序调用存储过程,在mysql命令行中调用call undobusiness();,会列出jz_business_plan的表中的内容,这张表会显示出列为:gp_id,g_id,remark,bs_id,gb_id,plandate,account_id,都会显示出来。

执行delete没有报错,就是删不掉数据,sql语句也有,求大神

package edu.jmi.xyh.view; import java.awt.BorderLayout; public class DeleteView extends JFrame { private JPanel contentPane; private JTextField txID; private JTextField txName; private JPasswordField txPw; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { DeleteView frame = new DeleteView(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public DeleteView() { setTitle("\u5220\u9664\u5B66\u751F\u4FE1\u606F"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel label = new JLabel("\u5220 \u9664 \u5B66 \u751F \u4FE1 \u606F"); label.setFont(new Font("宋体", Font.PLAIN, 16)); label.setBounds(140, 22, 147, 15); contentPane.add(label); JLabel lblId = new JLabel("\u7528 \u6237 ID\uFF1A"); lblId.setBounds(95, 55, 69, 15); contentPane.add(lblId); txID = new JTextField(); txID.setBounds(174, 52, 113, 21); contentPane.add(txID); txID.setColumns(10); JLabel label_2 = new JLabel("\u7528 \u6237 \u540D\uFF1A"); label_2.setBounds(95, 98, 66, 15); contentPane.add(label_2); JLabel label_3 = new JLabel("\u5BC6 \u7801\uFF1A"); label_3.setBounds(95, 143, 54, 15); contentPane.add(label_3); txName = new JTextField(); txName.setBounds(174, 95, 113, 21); contentPane.add(txName); txName.setColumns(10); JButton button = new JButton("\u5220\u9664"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String id=txID.getText(); String pw=txPw.getText(); String name=txName.getText(); Student student=new Student(); student.setStuId(id); student.setStuName(name); student.setStuPwd(pw); StudentDao studentDao=new StudentDao(); int result=studentDao.delete(id); if(result==0){ JOptionPane.showMessageDialog(null, "删除成功!"); } else{ JOptionPane.showMessageDialog(null, "删除失败!"); } System.out.println("id="+id+"pw="+pw); } }); button.setBounds(75, 189, 93, 23); contentPane.add(button); JButton button_1 = new JButton("\u53D6\u6D88"); button_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //生成一个对象 MainView mainView = new MainView(); //隐藏窗口 DeleteView.this.setVisible(false); mainView.setVisible(true); } }); button_1.setBounds(232, 189, 93, 23); contentPane.add(button_1); txPw = new JPasswordField(); txPw.setBounds(174, 140, 113, 21); contentPane.add(txPw); } public void setMainView(MainView mainView) { // TODO Auto-generated method stub } public void setID(Object id) { // TODO Auto-generated method stub } } 2.package edu.jmi.xyh.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import edu.jmi.xyh.bean.Student; public class StudentDao { //测试用 //ORM object relation mapping hibernate,ibaits //每一条记录映射每一个对象,记录集合映射成对象集合List //Dao data access object //save将一个java对象存储到数据库表中,就是将对象转换为记录 public int save(Student student){ //建立一个DBOperation,通过这个对象完成数据库的连接操作 DBOperation dboperation= new DBOperation(); //获取数据库连接 Connection connection=null; try{ connection=dboperation.getConnection(); Statement st=connection.createStatement(); //字符串拼接 String sql="insert into student(stuId,stuName,stuPwd)values('" +student.getStuId()+"','"+student.getStuName()+"','"+student.getStuPwd()+"')"; //用来在程序中指挥sql命令执行 st.execute(sql); System.out.println(sql); return 0; }catch(Exception ex){ ex.printStackTrace(); //返回上层判断 return -1; }finally{ dboperation.closeConnect(connection); } } public int update(Student student){ //建立一个DBOperation,通过这个对象完成数据库的连接操作 DBOperation dboperation= new DBOperation(); //获取数据库 Connection connection=null; try{ connection=dboperation.getConnection(); Statement st=connection.createStatement(); //字符串拼接 String sql="update student set stuName='"+student.getStuName()+ "', stuPwd='"+student.getStuPwd()+"' where stuId='"+ student.getStuId()+"'"; st.execute(sql); System.out.println(sql); return 0; }catch(Exception ex){ ex.printStackTrace(); //返回上层判断 return -1; }finally{ dboperation.closeConnect(connection); } } public int delete(Student student){ //建立一个DBOperation,通过这个对象完成数据库的连接操作 DBOperation dboperation= new DBOperation(); //获取数据库连接 Connection connection=null; try{ connection=dboperation.getConnection(); String sql="delete from student where stuId='?'"; //准备执行sql语句 PreparedStatement pst=connection.prepareStatement(sql); //替换上面的问号 pst.setString(1, student.getStuId()); pst.execute(); /* Statement st=connction.createStatement(); //字符串拼接 String sql="delete from student where Stuid='"+student.getStuid()+"'"; st.execute(sql);*/ //把sql语句打出来 System.out.println(sql); //返回值 return 0; //异常处理 }catch(Exception ex){ ex.printStackTrace(); //返回上层判断 return -1; }finally{ //关闭与数据库连接 dboperation.closeConnect(connection); } } //查询结果放到集合中,集合中的每一个对象都是student <>是泛型 public List<Student> query(){ //建立一个DBOperation,通过这个对象完成数据库的连接操作 DBOperation dboperation= new DBOperation(); //获取数据库 Connection connection=null; List<Student> list = new ArrayList<Student>(); try{ connection=dboperation.getConnection(); Statement st=connection.createStatement(); //查询语句 String sql="select* from student"; //查询语句执行exuecuteQuery,不是execte,执行后放回结果集resultset,把resultsest变成list,通过遍历实现 ResultSet rs=st.executeQuery(sql); //rs.next向下移动一行,刚开始在第0行。如果该行存在,返回true,否则会返回false, //每一行对应一个student对象,全部记录对应list //getInt,getString,getDate,getBoolean,获取该字段的值 //getInt(1),getInt("stuId") //可能有多条用while,最多用一条用if if(rs.next()){ Student student=new Student(); String stuId=rs.getString("stuId"); String stuName=rs.getString("stuName"); String stuPwd=rs.getString("stuPwd"); student.setStuId(stuId); student.setStuName(stuName); student.setStuPwd(stuPwd); //最后将student对象存放到集合中 list.add(student); } System.out.println(sql); return list; }catch(Exception ex){ ex.printStackTrace(); //返回上层判断 return null; }finally{ dboperation.closeConnect(connection); } } //重载 public static Student query(String id) { // TODO Auto-generated method stub //建立一个DBOperation,通过这个对象完成数据库的连接操作 DBOperation dbOperation=new DBOperation(); //获取数据库连接 Connection connction=null; try{ connction=dbOperation.getConnection(); Statement st=connction.createStatement(); //查询语句 String sql="select * from student where stuid='"+id+"'"; //查询语句执行exuecuteQuery,不是execute,执行后放回结果集resultset,把resultset变成list,通过遍历实现 ResultSet rs=st.executeQuery(sql); //可能有多条用while,最多一条就用if可以了。码农 Student student=null; if(rs.next()){ //如果有记录,新建一个student对象,将查到的结果封装到student对象中。 student=new Student(); String stuId=rs.getString("stuId"); String stuName=rs.getString("stuName"); String stuPwd=rs.getString("stuPwd"); student.setStuId(stuId); student.setStuName(stuName); student.setStuPwd(stuPwd); } return student; }catch(Exception ex){ ex.printStackTrace(); //返回上层判断 return null; }finally{ dbOperation.closeConnect(connction); } } public static void main(String args[]){ StudentDao studentDao=new StudentDao(); List<Student> list=studentDao.query(); //for each语句 iterator for(Student student:list){ System.out.println(student.getStuName()); } /*Student student=new Student(); student.setStuId("152118130235"); student.setStuName("徐耀辉"); student.setStuPwd("979194874");*/ } public int delete(String id) { // TODO Auto-generated method stub return 0; } }

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

汽车行驶工况构建2019 D题.zip

1. 标记0与0之间的片段位置 2.标记所之间的毛刺数的位置 3.去掉毛刺数据 速度 并生成 新的数组 4.标记时间段 5. 0与0之间 如果有不连续的时间片段 置零 先找到时间间隔 再看间隔时间对应

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉系统全面的介绍。

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

专为程序员设计的数学课

<p> 限时福利限时福利,<span>15000+程序员的选择!</span> </p> <p> 1、原价 115 元,限时特价仅需 49 元!<br> 2、购课后添加学习助手(微信号:csdnxy68),按提示消息领取编程大礼包!并获取讲师答疑服务! </p> <p> <br> </p> <p> 套餐中一共包含5门程序员必学的数学课程(共47讲) </p> <p> 课程1:《零基础入门微积分》 </p> <p> 课程2:《数理统计与概率论》 </p> <p> 课程3:《代码学习线性代数》 </p> <p> 课程4:《数据处理的最优化》 </p> <p> 课程5:《马尔可夫随机过程》 </p> <p> <br> </p> <p> 哪些人适合学习这门课程? </p> <p> 1)大学生,平时只学习了数学理论,并未接触如何应用数学解决编程问题; </p> <p> 2)对算法、数据结构掌握程度薄弱的人,数学可以让你更好的理解算法、数据结构原理及应用; </p> <p> 3)看不懂大牛代码设计思想的人,因为所有的程序设计底层逻辑都是数学; </p> <p> 4)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; </p> <p> 5)想修炼更好的编程内功,在遇到问题时可以灵活的应用数学思维解决问题。 </p> <p> <br> </p> <p> 在这门「专为程序员设计的数学课」系列课中,我们保证你能收获到这些:<br> <br> <span> </span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">①价值300元编程课程大礼包</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">②应用数学优化代码的实操方法</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">③数学理论在编程实战中的应用</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">④程序员必学的5大数学知识</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">⑤人工智能领域必修数学课</span> </p> <p> <br> 备注:此课程只讲程序员所需要的数学,即使你数学基础薄弱,也能听懂,只需要初中的数学知识就足矣。<br> <br> 如何听课? </p> <p> 1、登录CSDN学院 APP 在我的课程中进行学习; </p> <p> 2、登录CSDN学院官网。 </p> <p> <br> </p> <p> 购课后如何领取免费赠送的编程大礼包和加入答疑群? </p> <p> 购课后,添加助教微信:<span> csdnxy68</span>,按提示领取编程大礼包,或观看付费视频的第一节内容扫码进群答疑交流! </p> <p> <img src="https://img-bss.csdn.net/201912251155398753.jpg" alt=""> </p>

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

IE主页被篡改修复

IE主页修复。IE主页被篡改修复。一键修复IE主页

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

土豆SDK(Java版)-非官方

由于土豆SDK一直建设中,最近几天抽空写了一套java的SDK。包含了现有的所有请求协议。本套SDK中仅提供了oAuth的方式(引用oAuth.net的java版示例),并没有在框架中实现,涉及到登录

Java8零基础入门视频教程

这门课程基于主流的java8平台,由浅入深的详细讲解了java SE的开发技术,可以使java方向的入门学员,快速扎实的掌握java开发技术!

【数据结构与算法综合实验】欢乐连连看(C++ & MFC)案例

这是武汉理工大学计算机学院数据结构与算法综合实验课程的第三次项目:欢乐连连看(C++ & MFC)迭代开发代码。运行环境:VS2017。已经实现功能:开始游戏、消子、判断胜负、提示、重排、计时、帮助。

数学建模竞赛D题“汽车行驶工况构建

第十六届“华为杯”数学建模竞赛D题“汽车行驶工况构建”论文。论文获得比赛国家二等奖,论文为原创,仅供参考。 关键词:数据处理;降维;聚类。

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

Android音视频开发全套

Android平台音视频开发全套,涉及:FFmpeg软解码解码、Mediacodec硬解码编码、Openssl音频播放、OpenGL ES视频渲染、RTMP推流等核心重要知识点。

设计模式(JAVA语言实现)--20种设计模式附带源码

课程亮点: 课程培训详细的笔记以及实例代码,让学员开始掌握设计模式知识点 课程内容: 工厂模式、桥接模式、组合模式、装饰器模式、外观模式、享元模式、原型模型、代理模式、单例模式、适配器模式 策略模式、模板方法模式、观察者模式、迭代器模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式 课程特色: 笔记设计模式,用笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 笔记以超链接形式让知识点关联起来,形式知识体系 采用先概念后实例再应用方式,知识点深入浅出 提供授课内容笔记作为课后复习以及工作备查工具 部分图表(电脑PC端查看):

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

想学好JAVA必须要报两万的培训班吗? Java大神勿入 如果你: 零基础想学JAVA却不知道从何入手 看了一堆书和视频却还是连JAVA的环境都搭建不起来 囊中羞涩面对两万起的JAVA培训班不忍直视 在职没有每天大块的时间专门学习JAVA 那么恭喜你找到组织了,在这里有: 1. 一群志同道合立志学好JAVA的同学一起学习讨论JAVA 2. 灵活机动的学习时间完成特定学习任务+每日编程实战练习 3. 热心助人的助教和讲师及时帮你解决问题,不按时完成作业小心助教老师的家访哦 上一张图看看前辈的感悟: &nbsp; &nbsp; 大家一定迫不及待想知道什么是极简JAVA学习营了吧,下面就来给大家说道说道: 什么是极简JAVA学习营? 1. 针对Java小白或者初级Java学习者; 2. 利用9天时间,每天1个小时时间; 3.通过 每日作业 / 组队PK / 助教答疑 / 实战编程 / 项目答辩 / 社群讨论 / 趣味知识抢答等方式让学员爱上学习编程 , 最终实现能独立开发一个基于控制台的‘库存管理系统’ 的学习模式 极简JAVA学习营是怎么学习的? &nbsp; 如何报名? 只要购买了极简JAVA一:JAVA入门就算报名成功! &nbsp;本期为第四期极简JAVA学习营,我们来看看往期学员的学习状态: 作业看这里~ &nbsp; 助教的作业报告是不是很专业 不交作业打屁屁 助教答疑是不是很用心 &nbsp; 有奖抢答大家玩的很嗨啊 &nbsp; &nbsp; 项目答辩终于开始啦 &nbsp; 优秀者的获奖感言 &nbsp; 这是答辩项目的效果 &nbsp; &nbsp; 这么细致的服务,这么好的氛围,这样的学习效果,需要多少钱呢? 不要1999,不要199,不要99,只要9.9 是的你没听错,只要9.9以上所有就都属于你了 如果你: 1、&nbsp;想学JAVA没有基础 2、&nbsp;想学JAVA没有整块的时间 3、&nbsp;想学JAVA没有足够的预算 还等什么?赶紧报名吧,抓紧抢位,本期只招300人,错过只有等时间待定的下一期了 &nbsp; 报名请加小助手微信:eduxy-1 &nbsp; &nbsp;

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

web网页制作期末大作业

分享思维,改变世界. web网页制作,期末大作业. 所用技术:html css javascript 分享所学所得

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/27513,点击右下方课程资料、代码、课件等打包下载

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

C++语言基础视频教程

C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。

零基础学C#编程—C#从小白到大咖

本课程从初学者角度出发,提供了C#从入门到成为程序开发高手所需要掌握的各方面知识和技术。 【课程特点】 1 由浅入深,编排合理; 2 视频讲解,精彩详尽; 3 丰富实例,轻松易学; 4 每章总结配有难点解析文档。 15大章节,228课时,1756分钟与你一同进步!

编程实现学生基本信息管理程序

编程实现学生基本信息管理程序。学生基本信息包括:学号、姓名、性别、年龄、班级、学院、专业等。具体实现的管理功能如下: (1) 输入并显示多个学生的基本信息; (2) 可根据需要实现学生信息的添加; (

android 漂亮的UI界面 完整的界面设计

声明:这也是我学习时在网上下载的,鉴于分享精神,并且觉得很不错才上传上来的。。。。。 android 漂亮的UI界面 完整的界面设计 这是一个完整的UI设计,但是没写动作,这是一个公司程序员的公司任务

Anaconda详细安装及使用教程(带图文)

Anacond的介绍 Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB),如果只需要某些包,或者需要节省带宽或存储空间,也可以使用Miniconda这个较小的发行版(仅包含conda和 Python)。 Conda是一个开源的包、环境管理器,可以用于...

DirectX修复工具V4.0增强版

DirectX修复工具(DirectX Repair)是一款系统级工具软件,简便易用。本程序为绿色版,无需安装,可直接运行。 本程序的主要功能是检测当前系统的DirectX状态,如果发现异常则进行修复

相关热词 c#跨线程停止timer c#批量写入sql数据库 c# 自动安装浏览器 c#语言基础考试题 c# 偏移量打印是什么 c# 绘制曲线图 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行
立即提问