hibernate映射数据库timestamp为java.util.Date类型 丢失时间

数据库为mysql
hibernate3.0

连接驱动为3.1.13

 

数据库中的时间字段类型为timestamp,

实体类中属性类型为Date

映射如下

<property name="reserveDate" type="timestamp">

            <column name="reserveDate"  />

        </property>

或者

<property name="reserveDate" type="java.util.Date">

            <column name="reserveDate"  />

        </property>

在保存的时候都只保存了年月日,没有时分秒;求指教!

2个回答

个人觉得你可以这样
1 直接使用sql语句insert,看是不是有时分秒
2 使用纯jdbc来insert
这2步下来之后你应该就会知道是不是hibernate配置文件问题了,解决问题有时候需要一点一点排除,并不一定是你映射的问题。

new Timestamp((new java.util.Date()).getTime())

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
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

hibernate4 注解方式映射Date类型时间格式问题

private java.util.Date createTime = null 然后加了注解 @Temporal(TemporalType.TIMESTAMP) sql是自动生成, 数据库中的字段为TIMESTAMP类型 时间格式变成了12-MAY-18 10.05.25.861000 PM 实在是太丑了。这个时间格式怎么调整? 只要指成TemporalType.TIMESTAMP,数据库字段类型性就是TIMESTAMP 指定成TemporalType.TIME的话数据库是Date类型但是插入的是1970/1/1 22:04:30,日期不对。 指定成TemporalType.Date的话又没有时间。 请问数据时间格式怎么指定为2018/5/12 22:05:25类似这样格式呢?

hibernate为何返回的是timestamp

数据库字段类型为date。实体使用注解,映射为java.util.date,同时加上@Temporal(TemporalType.TIMESTAMP)。这样是为了保存时间。现在保存操作一切正常,时间也能保存。可是当前台查询时却返回一个timestamp,就像1313136222000。为什么不是返回2011-08-12 16:03:42这个日期呢?数据库里存的就是这个日期。我要怎样才能返回这个日期?需要转换么?如何操作?hibernate的日期让我很头痛

用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也没用,不知道问题出在哪里?

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,都会显示出来。

spring data jpa 一对多关系怎么配置

``` //实体类1 @Entity @Table(name = "t_user") //@Data //@ToString(exclude = {"role"}) public class TUser { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") private Integer id; private String username; private String password; private String email; private Integer sex;//性别,0.1.2(男,女,未知) private Date last_login; private Date create_time;//创建时间 private Date update_time;//修改时间 private String phone;//电话 private String photo;//图片地址 private Integer status;//状态,0正常,1禁止 @ManyToOne(cascade=CascadeType.PERSIST)//cascade=CascadeType.PERSIST(开启级联操作) @JoinColumn(name="roles_id") private TRole role; } //实体类2 @Entity @Table(name = "t_role") //@Data public class TRole { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") private Integer id; private String memo; private String r_name; private Date ctime; private Date update_time; @OneToMany(mappedBy="role") private Set<TUser> set = new HashSet<>(); } //dao层 public interface TUserDao extends JpaRepository<TUser, Integer>{ } //测试代码 @Autowired private TUserDao tuserDao; //添加 @Test public void add() { TRole role = new TRole(); role.setCtime(new Date()); role.setMemo("注解"); role.setR_name("管理员"); role.setUpdate_time(new Date()); TUser tUser = new TUser(); tUser.setCreate_time(new Date()); tUser.setEmail("1655@qa.com"); tUser.setLast_login(new Date()); tUser.setPassword("123456"); tUser.setPhone("www"); tUser.setPhoto("www.as"); tUser.setSex(0); tUser.setStatus(0); tUser.setUpdate_time(new Date()); tUser.setUsername("nichen"); role.getSet().add(tUser); tUser.setRole(role); tuserDao.save(tUser); } //查询 @Test public void findAll() { List<TUser> findAll = tuserDao.findAll(); for (TUser tUser : findAll) { System.out.println("tUser:"+tUser); } System.out.println("size:"+findAll.size()); } 这代码插入是可以的,查询就会有问题。 测试中的查询的错误:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.simulation.admin.model.TRole.set, could not initialize proxy - no Session at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:582) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:201) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:561) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:132) at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:299) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.simulation.admin.model.TRole.toString(TRole.java:99) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.simulation.admin.model.TUser.toString(TUser.java:166) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.simulation.admin.SimulationApplicationTests.findAll(SimulationApplicationTests.java:60) 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:498) 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.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) 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.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) 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:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) 如果是用服务的接口访问的错误:java.lang.StackOverflowError: null at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:449) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:136) ~[na:1.8.0_144] at java.sql.Timestamp.toString(Timestamp.java:302) ~[na:1.8.0_144] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:165) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at java.util.AbstractCollection.toString(AbstractCollection.java:462) ~[na:1.8.0_144] at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TRole.toString(TRole.java:99) ~[classes/:na] at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_144] at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_144] at com.simulation.admin.model.TUser.toString(TUser.java:166) ~[classes/:na] ```

新手求解一个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

springMVC 实体映射问题

/** *这里是表的结构 */ CREATE TABLE "PS"."U_BILL" ( "ID" NUMBER(11) NOT NULL , "BILL_NUM" VARCHAR2(16 CHAR) NULL , "BILL_STATUS" VARCHAR2(8 CHAR) NULL , "PAY_BACK_DATE" DATE NULL , "PAY_BACK_TIME" VARCHAR2(16 CHAR) NULL , "PAY_MONEY" NUMBER(25,10) NULL , "PAYGROUP_ID" NUMBER(25,10) NULL , "UUID" VARCHAR2(64 CHAR) NULL , "WHOCREATED" VARCHAR2(100 CHAR) NULL , "WHENCREATED" TIMESTAMP(6) DEFAULT SYSDATE NULL , "WHOMODIFIED" VARCHAR2(100 CHAR) NULL , "WHENMODIFIED" TIMESTAMP(6) NULL ) LOGGING NOCOMPRESS NOCACHE ; /** *这是我的实体类代码 */ package com.entity; import java.math.BigDecimal; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * U_BILL Entity @author sjy */ @Entity @Table(name = "U_BILL", schema = "PS") public class TUBill { private BigDecimal id; private String billNum; private String billStatus; private Date payBackDate; private double payMoney; private BigDecimal paygroupId; private String uuid; // Constructors /** default constructor */ public TUBill() { super(); } /** full constructor */ public TUBill(BigDecimal id, String billNum, String billStatus, Date payBackDate, double payMoney, BigDecimal paygroupId, String uuid) { super(); this.id = id; this.billNum = billNum; this.billStatus = billStatus; this.payBackDate = payBackDate; this.payMoney = payMoney; this.paygroupId = paygroupId; this.uuid = uuid; } // Property accessors @Id @Column(name = "ID", unique = true, nullable = false, precision = 11, scale = 0) public BigDecimal getId() { return id; } public void setId(BigDecimal id) { this.id = id; } @Column(name = "BILL_NUM", length = 16) public String getBillNum() { return billNum; } public void setBillNum(String billNum) { this.billNum = billNum; } @Column(name = "BILL_STATUS", length = 8) public String getBillStatus() { return billStatus; } public void setBillStatus(String billStatus) { this.billStatus = billStatus; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "PAY_BACK_DATE", length = 7) public Date getPayBackDate() { return payBackDate; } public void setPayBackDate(Date payBackDate) { this.payBackDate = payBackDate; } @Column(name = "PAY_MONEY", precision = 25, scale = 10) public double getPayMoney() { return payMoney; } public void setPayMoney(double payMoney) { this.payMoney = payMoney; } @Column(name = "PAYGROUP_ID", precision = 25, scale = 10) public BigDecimal getPayGroupid() { return paygroupId; } public void setPayGroupid(BigDecimal paygroupId) { this.paygroupId = paygroupId; } @Column(name = "UUID", length = 64) public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } } 请教各位大神,,我运行时候报错 org.springframework.orm.hibernate4.HibernateQueryException: could not resolve property: paygroupId of: com.entity.TUBill; nested exception is org.hibernate.QueryException: could not resolve property: paygroupId of: com.entity.TUBill 这个是因为我实体映射写错了吗?还是因为数据库中的类型和实体里面的类型没匹配上?这个怎么解决啊,求指教啊~~~~~~

晕死,有人见过类似的错误没?关于的hibernate的

我没分了 5......... 先来错误提示(首先说明不是简单的表不存在,所有的映射文件都没有映射过company表[至少没有显式引用]) [code="java"]ERROR 2009-09-10 13:31:58.343 JDBCExceptionReporter:logExceptions - Table 'bfw_utf8.company' doesn't exist org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: [com.bafang.pojos.SiteAd]; bad SQL grammar [insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519) at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:598) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358) at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:595) at com.bafang.pojos.base._BaseRootDAO.save(_BaseRootDAO.java:25) at com.bafang.pojos.base.BaseSiteAdDAO.save(BaseSiteAdDAO.java:20) at com.bafang.pojos.base.BaseSiteAdDAO$$FastClassByCGLIB$$33c630a7.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:609) at com.bafang.pojos.dao.SiteAdDAO$$EnhancerByCGLIB$$29bf5095.save(<generated>) at com.bafang.web.action.admin.main.AdAction.add(AdAction.java:107) 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.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at com.bafang.web.servlet.BFActionServlet.process(BFActionServlet.java:26) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.HTMLFilter.synthesisURI(HTMLFilter.java:85) at com.bafang.web.filters.HTMLFilter.doFilter(HTMLFilter.java:60) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.AdminFilter.doFilter(AdminFilter.java:41) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.SubsiteFilter.doFilter(SubsiteFilter.java:35) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:619)[/code] 相关hibernate映射文件 SiteAd.hbm.xml [code="xml"]<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.bafang.pojos"> <class name="SiteAd" table="site_ad"> <id name="id" type="integer" column="id"> <generator class="identity" /> </id> <property name="subsiteId" column="subsite_id" type="integer" not-null="false" length="11" /> <property name="siteAdLocationId" column="site_ad_location_id" type="string" not-null="false" length="50" /> <property name="siteAdLocationName" column="site_ad_location_name" type="string" not-null="false" length="255" /> <many-to-one name="siteAdLocation" column="site_ad_location_id" class="SiteAdLocation" not-null="false" insert="false" update="false" /> <property name="siteAdKeywordId" column="site_ad_keyword_id" type="integer" not-null="false" length="11" /> <property name="siteAdKeyword" column="site_ad_keyword" type="string" not-null="false" length="255" /> <property name="companyId" column="company_id" type="integer" not-null="false" length="11" /> <property name="companyName" column="company_name" type="string" not-null="false" length="255" /> <!--<many-to-one name="company" column="company_id" class="Store" not-null="false" insert="false" update="false" />--> <property name="txt" column="txt" type="string" not-null="false" length="255" /> <property name="url" column="url" type="string" not-null="false" length="255" /> <property name="mediaType" column="media_type" type="string" not-null="false" length="255" /> <property name="mediaFile" column="media_file" type="string" not-null="false" length="255" /> <property name="type" column="type" type="string" not-null="false" length="100" /> <property name="charge" column="charge" type="java.lang.Float" not-null="false" length="12" /> <property name="startTime" column="start_time" type="timestamp" not-null="false" length="19" /> <property name="endTime" column="end_time" type="timestamp" not-null="false" length="19" /> <property name="itemOrder" column="item_order" type="integer" not-null="false" length="11" /> <property name="enabled" column="enabled" type="boolean" not-null="false" length="1" /> </class> </hibernate-mapping>[/code] pojo相关类 com.bafang.pojos.SiteAd.java [code="java"]package com.bafang.pojos; import com.bafang.pojos.base.BaseSiteAd; public class SiteAd extends BaseSiteAd { private static final long serialVersionUID = 7092206885096359130L; public SiteAd () { } public String getTypeName(){ if("1".equals(getType())) return "多媒体广告"; else if("2".equals(getType())) return "连接广告"; else if("3".equals(getType())) return "店铺广告"; else if("4".equals(getType())) return "店铺评论广告"; else return "其它广告"; } }[/code] com.bafang.pojos.base.BaseSiteAd.java [code="java"]package com.bafang.pojos.base; import java.io.Serializable; public abstract class BaseSiteAd implements Serializable { protected Integer id; protected Integer subsiteId; protected String siteAdLocationId; protected String siteAdLocationName; protected Integer siteAdKeywordId; protected String siteAdKeyword; protected Integer companyId; protected String companyName; protected String txt; protected String url; protected String mediaType; protected String mediaFile; protected String type; protected Float charge; protected java.util.Date startTime; protected java.util.Date endTime; protected Integer itemOrder; protected Boolean enabled; protected com.bafang.pojos.SiteAdLocation siteAdLocation; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getSubsiteId() { return subsiteId; } public void setSubsiteId(Integer subsiteId) { this.subsiteId = subsiteId; } public String getSiteAdLocationId() { return siteAdLocationId; } public void setSiteAdLocationId(String siteAdLocationId) { this.siteAdLocationId = siteAdLocationId; } public String getSiteAdLocationName() { return siteAdLocationName; } public void setSiteAdLocationName(String siteAdLocationName) { this.siteAdLocationName = siteAdLocationName; } public Integer getSiteAdKeywordId() { return siteAdKeywordId; } public void setSiteAdKeywordId(Integer siteAdKeywordId) { this.siteAdKeywordId = siteAdKeywordId; } public String getSiteAdKeyword() { return siteAdKeyword; } public void setSiteAdKeyword(String siteAdKeyword) { this.siteAdKeyword = siteAdKeyword; } public Integer getCompanyId() { return companyId; } public void setCompanyId(Integer companyId) { this.companyId = companyId; } public String getCompanyName() { return companyName; } public void setCompanyName(String companyName) { this.companyName = companyName; } public String getTxt() { return txt; } public void setTxt(String txt) { this.txt = txt; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getMediaType() { return mediaType; } public void setMediaType(String mediaType) { this.mediaType = mediaType; } public String getMediaFile() { return mediaFile; } public void setMediaFile(String mediaFile) { this.mediaFile = mediaFile; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Float getCharge() { return charge; } public void setCharge(Float charge) { this.charge = charge; } public java.util.Date getStartTime() { return startTime; } public void setStartTime(java.util.Date startTime) { this.startTime = startTime; } public java.util.Date getEndTime() { return endTime; } public void setEndTime(java.util.Date endTime) { this.endTime = endTime; } public Integer getItemOrder() { return itemOrder; } public void setItemOrder(Integer itemOrder) { this.itemOrder = itemOrder; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } public com.bafang.pojos.SiteAdLocation getSiteAdLocation() { return siteAdLocation; } public void setSiteAdLocation(com.bafang.pojos.SiteAdLocation siteAdLocation) { this.siteAdLocation = siteAdLocation; } }[/code] 保存动作是直接调用spring的工具类 org.springframework.orm.hibernate3.support.HibernateDaoSupport.save(Object obj); 我debug过,就是保存的动作后报的错 数据库query 日志 [code="java"]090910 13:31:50 2 Query SET autocommit=0 2 Prepare select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit ? 2 Execute select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit 20 2 Close stmt 2 Query commit 2 Query SET autocommit=1 2 Query SET autocommit=0 2 Prepare select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=? 2 Execute select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 2 Close stmt 2 Query commit 2 Query SET autocommit=1 090910 13:31:58 2 Prepare insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2 Query select name into str from site_ad_location where id=new.site_ad_location_id 2 Query select name into str from company where id=new.company_id 2 Query SELECT 1 2 Close stmt D:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.37-community-log (MySQL Community Server (GPL)). started with: TCP Port: 3306, Named Pipe: (null) Time Id Command Argument 090910 13:33:15 1 Connect root@localhost on 1 Query SET NAMES utf8 2 Connect root@localhost on 2 Query SELECT @@sql_mode 2 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 2 Query SET NAMES utf8 2 Quit 090910 13:33:17 1 Quit 3 Connect root@localhost on 3 Query SELECT @@sql_mode 3 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 3 Query SET NAMES utf8[/code] [b]问题补充:[/b] [quote]dwangel[/quote]已经清理过项目 还是一样 谢谢啊 已经找到问题了 以前写成的程序员 弄了个触发器在数据库里 刚刚发现的 谢谢了 分不多都给你了

关于hibernateTemplate里的find(String, Object[])这个重载的方法

找不到spring-hibernate.jar的源代码,所以请教一下大家 这个方法里传的Object[]应该是hql语句中占位符的参数了吧,这里是不是任何类型都可以赋值进去,尤其包括日期时间类型,Date,TimeStamp等 注:我知道Query接口里的setParameter(String, Object),如果是日期类型就要指定Hibernate的Type [b]问题补充:[/b] setParameter里如果参数是Date、TimeStamp等类型,要指定Hibernate的Type吧,既然find里就是用的query.setParameter实现的,那它是不是不完善啊 [b]问题补充:[/b] 拜托请先看我问题补充,有的参数必须要指定类型,比如日期或时间的,因为有很多种类型sql.Date,util.Date,TimeStamp等 [b]问题补充:[/b] lovewhzlq 我真服了你了 说点有用的行吗 没看人家楼上的已经把源码给出来了吗 不用你往这充数来 最鄙视这种人

hibernate自关联问题

&nbsp;&nbsp;&nbsp; 比如我要定义一个用户实体,如User。在这个用户实体里面,我想要定义用户的好友、黑名单和关注对象。于是我用了Set&lt;User&gt;的方式,然后在配置文件中使用了&lt;Set&gt;的配置,Set内使用many-to-many方式。我的目的就是让User自关联对多对,生成一个中间表,如User_friends。这样一来在运行的时候没问题,能生成所有预想的表,且能插入数据到User_INFO(User对应的表)中,但无论如何都不能将数据写入到对多对的关联表中。请高手们赐教,感谢不尽。 <br /> <br /><pre name="code" class="java"> package org.fantasizer.blog.core.entity; import java.io.Serializable; import java.util.Date; import java.util.Set; /** * [CN]用户实体 * * @author Marco Jee * @date 2010-11-1 */ @SuppressWarnings("serial") public class User implements Serializable { // ----------------------Instance Variables---------------------------// private Long id;// primary key private String loginname;// 登录名 private String nickname;// 昵称 private String password;// 密码MD5码 private String email;// email private Date birthdate;// 生日 private String gender;// 性别 private String marriage;// 婚姻状况 private String msn;// msn private String qq;// qq private String phone;// 电话号码 private String realname;// 真实姓名 private String country;// 国家 private String address;// 地址 private String birthplace;// 出生地 private String schoolname; private String strongSuit;// 特长 private String personalSign;// 个性签名 private Date lastLoginTime;// 上次登录时间 private Date lastLogoutTime;// 上次注销时间 private Date registerTime;// 注册时间 private Date loginTime;// 本次登录时间 private Integer loginCount;// 登录次数 private String lastIp;// 上次登录IP private String ip;// 本次登录IP private Boolean disabled;// 是否可用 private String picture;// 头像路径 private Set&lt;User&gt; friends;// 好友 private Set&lt;User&gt; attentions;// 关注对象 private Set&lt;User&gt; blcaklist;// 黑名单 // ----------------------Getters and Setters---------------------------// //Getters和Setters以及equals与hashCode方法由于太长,在此省略 } </pre> <br /><pre name="code" class="xml"> &lt;?xml version="1.0"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; &lt;hibernate-mapping package="org.fantasizer.blog.core.entity"&gt; &lt;class name="User" table="user_info" lazy="false"&gt; &lt;id name="id" column="userid"&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="loginname" column="loginname" type="string" length="20" unique="true" not-null="true" /&gt; &lt;property name="nickname" column="nickname" type="string" length="20" not-null="true" /&gt; &lt;property name="password" column="password" type="string" length="50" not-null="true" /&gt; &lt;property name="email" column="email" type="string" length="50" not-null="true" unique="true" /&gt; &lt;property name="birthdate" column="birthdate" type="date" /&gt; &lt;property name="gender" column="gender" type="string" length="6" /&gt; &lt;property name="marriage" column="marriage" type="string" length="6" /&gt; &lt;property name="msn" column="msn" type="string" length="50" /&gt; &lt;property name="qq" column="qq" type="string" length="50" /&gt; &lt;property name="phone" column="phone" type="string" length="15" /&gt; &lt;property name="realname" column="realname" type="string" length="50" /&gt; &lt;property name="country" column="country" type="string" length="50" /&gt; &lt;property name="address" column="address" type="string" length="100" /&gt; &lt;property name="birthplace" column="birthplace" type="string" length="100" /&gt; &lt;property name="schoolname" column="schoolname" type="string" length="50" /&gt; &lt;property name="strongSuit" column="strongSuit" type="string" length="200" /&gt; &lt;property name="personalSign" column="personalSign" type="string" length="200" /&gt; &lt;property name="lastLoginTime" column="lastLoginTime" type="timestamp" /&gt; &lt;property name="lastLogoutTime" column="lastLogoutTime" type="timestamp" /&gt; &lt;property name="registerTime" column="registerTime" type="timestamp" /&gt; &lt;property name="loginTime" column="loginTime" type="timestamp" /&gt; &lt;property name="loginCount" column="loginCount" type="java.lang.Integer" /&gt; &lt;property name="lastIp" column="lastIp" type="string" length="15" /&gt; &lt;property name="ip" column="ip" type="string" length="15" /&gt; &lt;property name="disabled" column="disabled" type="boolean" /&gt; &lt;property name="picture" column="picture" type="string" length="100" /&gt; &lt;set name="friends" inverse="true" table="user_friends" lazy="false"&gt; &lt;key column="userid" /&gt; &lt;many-to-many class="User" column="friendid" /&gt; &lt;/set&gt; &lt;set name="attentions" inverse="true" table="User_attentions"&gt; &lt;key column="userid" /&gt; &lt;many-to-many class="User" column="attentionid" /&gt; &lt;/set&gt; &lt;set name="blcaklist" inverse="true" table="user_blacklist"&gt; &lt;key column="userid" /&gt; &lt;many-to-many class="User" column="blcaklistid" /&gt; &lt;/set&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </pre> <br /> <br />另外补充一下,使用Hibernate的时候,想UserRelationship这样的类能不能当成实体?即表达的不是独立的实体,而是表示实体与实体之间关系的,谢谢各位~ <br/><strong>问题补充</strong><br/><div class="quote_title">txc_tang 写道</div> <div class="quote_div"> <p>帮你写了一个Annotation的实体类,映射关系劳烦你自己转换下,希望对你有用,呵呵</p> <pre name="code" class="java">package com.bebig.shopping.model; import java.util.Date; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name = "tbl_QQUser") public class QQUser { private Long id;// primary key private String loginname;// 登录名 private String nickname;// 昵称 private String password;// 密码MD5码 private String email;// email private Date birthdate;// 生日 private String gender;// 性别 private String marriage;// 婚姻状况 private String msn;// msn private String qq;// qq private String phone;// 电话号码 private String realname;// 真实姓名 private String country;// 国家 private String address;// 地址 private String birthplace;// 出生地 private String schoolname; private String strongSuit;// 特长 private String personalSign;// 个性签名 private Date lastLoginTime;// 上次登录时间 private Date lastLogoutTime;// 上次注销时间 private Date registerTime;// 注册时间 private Date loginTime;// 本次登录时间 private Integer loginCount;// 登录次数 private String lastIp;// 上次登录IP private String ip;// 本次登录IP private Boolean disabled;// 是否可用 private String picture;// 头像路径 private Set&lt;QQUser&gt; friends = new HashSet&lt;QQUser&gt;();// 好友 private Set&lt;QQUser&gt; attentions= new HashSet&lt;QQUser&gt;();// 关注对象 private Set&lt;QQUser&gt; blcaklist= new HashSet&lt;QQUser&gt;();// 黑名单 public String getAddress() { return address; } @ManyToMany(cascade={CascadeType.ALL}) @JoinTable(name = "tbl_QQUserAndAttentions", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = { @JoinColumn(name = "attentionId") }) public Set&lt;QQUser&gt; getAttentions() { return attentions; } public Date getBirthdate() { return birthdate; } public String getBirthplace() { return birthplace; } @ManyToMany(cascade={CascadeType.ALL}) @JoinTable(name = "tbl_QQUserAndBlcaklist", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = { @JoinColumn(name = "blcaklistId") }) public Set&lt;QQUser&gt; getBlcaklist() { return blcaklist; } public String getCountry() { return country; } public Boolean getDisabled() { return disabled; } public String getEmail() { return email; } @ManyToMany(cascade={CascadeType.ALL}) @JoinTable(name = "tbl_QQUserAndFriends", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = { @JoinColumn(name = "friendId") }) public Set&lt;QQUser&gt; getFriends() { return friends; } public String getGender() { return gender; } @Id @GeneratedValue public Long getId() { return id; } public String getIp() { return ip; } public String getLastIp() { return lastIp; } public Date getLastLoginTime() { return lastLoginTime; } public Date getLastLogoutTime() { return lastLogoutTime; } public Integer getLoginCount() { return loginCount; } public String getLoginname() { return loginname; } public Date getLoginTime() { return loginTime; } public String getMarriage() { return marriage; } public String getMsn() { return msn; } public String getNickname() { return nickname; } public String getPassword() { return password; } public String getPersonalSign() { return personalSign; } public String getPhone() { return phone; } public String getPicture() { return picture; } public String getQq() { return qq; } public String getRealname() { return realname; } public Date getRegisterTime() { return registerTime; } public String getSchoolname() { return schoolname; } public String getStrongSuit() { return strongSuit; } public void setAddress(String address) { this.address = address; } public void setAttentions(Set&lt;QQUser&gt; attentions) { this.attentions = attentions; } public void setBirthdate(Date birthdate) { this.birthdate = birthdate; } public void setBirthplace(String birthplace) { this.birthplace = birthplace; } public void setBlcaklist(Set&lt;QQUser&gt; blcaklist) { this.blcaklist = blcaklist; } public void setCountry(String country) { this.country = country; } public void setDisabled(Boolean disabled) { this.disabled = disabled; } public void setEmail(String email) { this.email = email; } public void setFriends(Set&lt;QQUser&gt; friends) { this.friends = friends; } public void setGender(String gender) { this.gender = gender; } public void setId(Long id) { this.id = id; } public void setIp(String ip) { this.ip = ip; } public void setLastIp(String lastIp) { this.lastIp = lastIp; } public void setLastLoginTime(Date lastLoginTime) { this.lastLoginTime = lastLoginTime; } public void setLastLogoutTime(Date lastLogoutTime) { this.lastLogoutTime = lastLogoutTime; } public void setLoginCount(Integer loginCount) { this.loginCount = loginCount; } public void setLoginname(String loginname) { this.loginname = loginname; } public void setLoginTime(Date loginTime) { this.loginTime = loginTime; } public void setMarriage(String marriage) { this.marriage = marriage; } public void setMsn(String msn) { this.msn = msn; } public void setNickname(String nickname) { this.nickname = nickname; } public void setPassword(String password) { this.password = password; } public void setPersonalSign(String personalSign) { this.personalSign = personalSign; } public void setPhone(String phone) { this.phone = phone; } public void setPicture(String picture) { this.picture = picture; } public void setQq(String qq) { this.qq = qq; } public void setRealname(String realname) { this.realname = realname; } public void setRegisterTime(Date registerTime) { this.registerTime = registerTime; } public void setSchoolname(String schoolname) { this.schoolname = schoolname; } public void setStrongSuit(String strongSuit) { this.strongSuit = strongSuit; } }</pre> </div> <p>哥们儿,非常感谢你的回复。不过我对Annotation理解不深呀,只有继续坐等了。。</p> <p> </p> <p>在此感谢~~</p>

freemarker的时间显示如何处理啊

我对freemarker不熟悉 我的工程:struts2+spring+hiberante+freemarker 一个时间字段:createdate java类型是:Calendar ,mysql类型:Timestamp,hibernate类型:Calender 数据库中存数的数据:2009-12-29 13:28:24 我想要页面上显示:2009-12-29 13:28:24 这个样子 页面上是freemarker输出的 怎么实现呢? [b]问题补充:[/b] <#setting datetime_format="yyyy-MM-dd HH:mm:Ss"/> 可不可以说的详细点 这是在哪里setting的、、 我的页面显示: 这块的循环代码 <#if page?? > <#list page.data as a> <#if a.id??> <tr> <th>[color=red]${a.createdate}[/color]这里的时间 &nbsp;|&nbsp;${a.ip}</th> <th width="100">${a.score}</th> <th width="80"><a href="../pj/replylist?id=${a.id}">回复</a></th> </tr> </#if> <br/> </#list> </#if> 我这里的时间createdate从数据库查询输出后是这么段玩意: java.util.GregorianCalendar[time=1262064504000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=11,WEEK_OF_YEAR=1,WEEK_OF_MONTH=5,DAY_OF_MONTH=29,DAY_OF_YEAR=363,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=28,SECOND=24,MILLISECOND=0,ZONE_OFFSET=28800000,DST_OFFSET=0] | 192.168.1.1 [b]问题补充:[/b] 再补充一个 freemarker的属性文件freemarker.properties 在哪里配置一下。才能在整个工程中起作用呢? [b]问题补充:[/b] [color=red]再补充一个 freemarker的属性文件freemarker.properties 在哪里配置一下。才能在整个工程中起作用呢? [/color] 不好意思重复了。是积分不够没办法发俩帖子。 [b]问题补充:[/b] 我的页面没有用struts2的标签,只是普通的html。加freemarker标签。而且页面文件的后缀是.html.不是.ftl 你说的<#setting datetime_format="yyyy-MM-dd HH:mm:Ss"/> 在我的页面中不起作用 我用freemarker.properties也不起作用 。 [b]问题补充:[/b] 因为mysql库中。我设置的这个字段为Timestamp类型,java中设置这个字段为Calendar类型。 [b]问题补充:[/b] java代码:Date类型 mysql字段:timestamp类型 hiberante映射:timestamp类型 模板页面加上:<#setting datetime_format="yyyy-MM-dd HH:mm:Ss"/> 模板页面显示:${a.createdate} 果然得到结果:2009-12-29 13:28:024 可以了。感谢蔡华江 (架构师) 2

Spring集成Hibernate,使用JPA注解方式,新增数据无法提交

<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>环境:</p> <p style="padding-left: 60px;">spring 3.1</p> <p style="padding-left: 60px;">hibernate 4.2.8 final </p> <p style="padding-left: 60px;">mysql 5.6</p> <p>问题描述:</p> <p style="padding-left: 30px;">调用controller的查询方法,可以正常返回数据</p> <p style="padding-left: 30px;">调用controller的创建方法,即:新增数据,控制台打印出了读取和修改序号表的sql,但是没有打印插入数据的sql,数据库表中也没有新增数据。</p> <p style="padding-left: 30px;">怀疑是spring控制的事务没有提交,但是排查了两三天,从网上找了各种方法,都没有解决问题。</p> <p style="padding-left: 30px;">请各位大侠拉小弟一把,实在是找不到事务为什么没有提交。</p> <p> </p> <p style="padding-left: 30px;">web.xml</p> <p style="padding-left: 30px;"> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;!-- 欢迎界面 --&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;!-- spring框架 --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- 上下文配置 --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt; /WEB-INF/applicationContext.xml, /WEB-INF/config/**/*.xml &lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- spring mvc --&gt; &lt;servlet&gt; &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt; &lt;!-- 拦截所有url --&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;!-- 回话有效期30分钟 --&gt; &lt;session-config&gt; &lt;session-timeout&gt;30&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;!-- log4j日志 --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- log4j日志配置 --&gt; &lt;context-param&gt; &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/properties/log4j.properties&lt;/param-value&gt; &lt;/context-param&gt; &lt;/web-app&gt;</pre> <p> applicationContext.xml</p> <p> </p> <p style="padding-left: 30px;"> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;!-- 注解配置 --&gt; &lt;context:annotation-config /&gt; &lt;!--允许使用注解方式配置事务 --&gt; &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt; &lt;!-- 自动扫描的包名 --&gt; &lt;context:component-scan base-package="com.lxl" /&gt; &lt;!-- 对标注@PersistenceContext的类经行增强,引入代理后的EntityManager实例 --&gt; &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt; &lt;!-- 对标注@Repository的类经行增强,将EntityManager异常转换为SpringDAO体系的异常 --&gt; &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt; &lt;!-- 属性文件 --&gt; &lt;context:property-placeholder location="/WEB-INF/properties/**/*.properties" /&gt; &lt;!-- 数据源 --&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt; &lt;property name="url" value="${jdbc.url}" /&gt; &lt;property name="username" value="${jdbc.username}" /&gt; &lt;property name="password" value="${jdbc.password}" /&gt; &lt;/bean&gt; &lt;!-- JPA 实体管理工厂 --&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" /&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="persistenceUnitName" value="ServicePlatform" /&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="showSql" value="true" /&gt; &lt;property name="generateDdl" value="true" /&gt; &lt;property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" /&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;!-- JPA 事务管理 --&gt; &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;/bean&gt; &lt;/beans&gt;</pre> <p> dispatcher-servlet.xml</p> <p> </p> <p style="padding-left: 30px;"> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;!-- 默认的注解映射的支持 --&gt; &lt;mvc:annotation-driven /&gt; &lt;!-- 自动扫描的包名 --&gt; &lt;context:component-scan base-package="com.lxl" /&gt; &lt;!-- 配置一下对json数据的转换 &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt; &lt;property name="messageConverters"&gt; &lt;list&gt; &lt;bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;&lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; --&gt; &lt;!-- 视图解析器 --&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/view" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;!-- 对静态资源文件的访问 方案一 (二选一) --&gt; &lt;mvc:default-servlet-handler /&gt; &lt;!-- 对静态资源文件的访问 方案二 (二选一) &lt;mvc:resources mapping="/images/**" location="/images/" cache-period="31556926"/&gt; &lt;mvc:resources mapping="/js/**" location="/js/" cache-period="31556926"/&gt; &lt;mvc:resources mapping="/css/**" location="/css/" cache-period="31556926"/&gt; --&gt; &lt;/beans&gt;</pre> <p> </p> <p> </p> <p style="padding-left: 30px;">persistence.xml</p> <p style="padding-left: 30px;"> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt; &lt;persistence-unit name="ServicePlatform" transaction-type="RESOURCE_LOCAL"&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </pre> <p> </p> <p> </p> <p style="padding-left: 30px;">实体bean</p> <p style="padding-left: 30px;"> </p> <pre name="code" class="java">package com.lxl.bsp.identity.entity; import java.io.Serializable; import java.sql.Timestamp; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "bd_id") public class Identity implements Serializable { private static final long serialVersionUID = -8763611811485844772L; @Id @GeneratedValue(strategy = GenerationType.TABLE) private Long id; @Column(length = 100) private String code; private Long value; @Column(length = 10) private String prefix; @Column(length = 10) private String suffix; @Column(length = 255) private String description; private Integer length; @Column(length = 30) private String creator; @Column(name = "create_date") private Timestamp createDate; @Column(length = 30) private String modifier; @Column(name = "modify_Date") private Timestamp modifyDate; private Boolean dr; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public Long getValue() { return value; } public void setValue(Long value) { this.value = value; } public String getPrefix() { return prefix; } public void setPrefix(String prefix) { this.prefix = prefix; } public String getSuffix() { return suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Integer getLength() { return length; } public void setLength(Integer length) { this.length = length; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator; } public Timestamp getCreateDate() { return createDate; } public void setCreateDate(Timestamp createDate) { this.createDate = createDate; } public String getModifier() { return modifier; } public void setModifier(String modifier) { this.modifier = modifier; } public Timestamp getModifyDate() { return modifyDate; } public void setModifyDate(Timestamp modifyDate) { this.modifyDate = modifyDate; } public Boolean getDr() { return dr; } public void setDr(Boolean dr) { this.dr = dr; } @Override public String toString() { return "Identity [id=" + id + ", code=" + code + ", value=" + value + ", prefix=" + prefix + ", suffix=" + suffix + ", description=" + description + ", length=" + length + ", creator=" + creator + ", createDate=" + createDate + ", modifier=" + modifier + ", modifyDate=" + modifyDate + ", dr=" + dr + "]"; } } </pre> <p> </p> <p> </p> <p style="padding-left: 30px;">IdentityDaoImpl.java</p> <p style="padding-left: 30px;"> </p> <pre name="code" class="java">package com.lxl.bsp.identity.dao; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.lxl.bsp.api.exception.ServicePlatformException; import com.lxl.bsp.identity.entity.Identity; @Repository public class IdentityDaoImpl implements IIdentityDao { @PersistenceContext private EntityManager em; @Transactional(propagation = Propagation.REQUIRED) public Identity create(Identity data) { em.persist(data); return data; } @Override public Identity retriver(String id) throws ServicePlatformException { Long pk = Long.valueOf(id); return em.find(Identity.class, pk); } @Override public Identity update(Identity data) throws ServicePlatformException { em.persist(data); return data; } @Override public void delete(String id) throws ServicePlatformException { em.remove(retriver(id)); } } </pre> <p> IdentityController.java</p> <p> </p> <p style="padding-left: 30px;"> </p> <pre name="code" class="java">package com.lxl.bsp.identity.controller; import java.sql.Timestamp; import java.util.Calendar; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lxl.bsp.api.exception.ServicePlatformException; import com.lxl.bsp.identity.dao.IIdentityDao; import com.lxl.bsp.identity.entity.Identity; @Controller @RequestMapping("identity") public class IdentityController { private static Log log = LogFactory.getLog(IdentityController.class); @Resource private IIdentityDao dao; @RequestMapping("retriver") @ResponseBody public Identity retriver(@RequestParam String id) throws ServicePlatformException { return dao.retriver(id); } @RequestMapping("create") @ResponseBody public Identity create() throws ServicePlatformException { int i = 1; Identity data = new Identity(); data.setCode("code" + i); Calendar c = Calendar.getInstance(); data.setCreateDate(new Timestamp(c.getTime().getTime())); data.setCreator("creator" + i); data.setDescription("description" + i); data.setDr(false); // data.setId("id" + Integer.toString(i)); data.setLength(30); data.setModifier("modifier" + i); data.setModifyDate(new Timestamp(c.getTime().getTime())); data.setPrefix("prefix"); data.setSuffix("suffix"); data.setValue(0L); Identity returnData = dao.create(data); log.debug(returnData); return returnData; } @RequestMapping("update") @ResponseBody public Identity update() throws ServicePlatformException { int i = 1; Identity data = new Identity(); data.setCode("1"); Calendar c = Calendar.getInstance(); data.setCreateDate(new Timestamp(c.getTime().getTime())); data.setCreator("creator" + i); data.setDescription("description" + i); data.setDr(false); // data.setId("id" + Integer.toString(i)); data.setLength(30); data.setModifier("modifier" + i); data.setModifyDate(new Timestamp(c.getTime().getTime())); data.setPrefix("prefix"); data.setSuffix("suffix"); data.setValue(0L); Identity returnData = dao.update(data); log.debug(returnData); return returnData; } @RequestMapping("delete") public void delete(@RequestParam String id) throws ServicePlatformException { dao.delete(id); } } </pre> <p> </p> <p> </p> <p style="padding-left: 30px;">数据表结构DDL</p> <p style="padding-left: 30px;"> </p> <pre name="code" class="sql">-- ---------------------------- -- Table structure for bd_id -- ---------------------------- DROP TABLE IF EXISTS `bd_id`; CREATE TABLE `bd_id` ( `id` bigint(30) NOT NULL, `code` varchar(100) DEFAULT NULL, `create_date` datetime DEFAULT NULL, `creator` varchar(30) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `dr` tinyint(1) DEFAULT NULL, `length` int(11) DEFAULT NULL, `modifier` varchar(30) DEFAULT NULL, `modify_Date` datetime DEFAULT NULL, `prefix` varchar(10) DEFAULT NULL, `suffix` varchar(10) DEFAULT NULL, `value` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre> <p> </p> <p> </p> <p style="padding-left: 30px;">附件中是项目压缩包,只要电脑上安装了数据库,解压即可运行,数据库名称是osd</p> <p> </p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

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

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

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

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

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

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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

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

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

阿里面试官让我用Zk(Zookeeper)实现分布式锁

他可能没想到,我当场手写出来了

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

​能让德国人放弃现金支付​,也没谁了

在新冠疫情中,德国人越来越多地选择在超市,加油站或其他商店付款时使用非接触式付款方式。德国信贷协会Deutschen Kreditwirtschaft (DK) 的一位发言人告诉德国新...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

2020春招面试了10多家大厂,我把问烂了的数据库事务知识点总结了一下

2020年截止目前,我面试了阿里巴巴、腾讯、美团、拼多多、京东、快手等互联网大厂。我发现数据库事务在面试中出现的次数非常多。

立即提问
相关内容推荐