- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试添加应用程序和应用程序设置时,出现以下错误。
这是详细的错误消息:
org.hibernate.exception.ConstraintViolationException: could not
execute statement at
org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:72)
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
at
org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
at
org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3558)
at
org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:492)
at
org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:197)
at
org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:181)
at
org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:216)
at
org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:334)
at
org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:289)
at
org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:195)
at
org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
at
org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
at
org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707) at
org.hibernate.internal.SessionImpl.save(SessionImpl.java:702) at
com.ips.tvadmindao.services.TVAppService.addTVappsWithSettings(TVAppService.java:237)
at TVAppserviseTest.testsSaveApps(TVAppserviseTest.java:46) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) 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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
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:675)
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:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Column 'company_id' cannot be null at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400) at
com.mysql.jdbc.Util.getInstance(Util.java:383) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783) at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447) at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545) at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2113)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2049)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2034)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:147)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
... 50 more
2015-12-21 21:23:15 DEBUG SqlExceptionHelper:139 - could not execute
statement [n/a]
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Column 'company_id' cannot be null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2113)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2049)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2034)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:147)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3558)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:492)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:197)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:181)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:216)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:334)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:289)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:195)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702)
at com.ips.tvadmindao.services.TVAppService.addTVappsWithSettings(TVAppService.java:237)
at TVAppserviseTest.testsSaveApps(TVAppserviseTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
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:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
2015-12-21 21:23:15 WARN SqlExceptionHelper:144 - SQL Error: 1048, SQLState: 23000
2015-12-21 21:23:15 ERROR SqlExceptionHelper:146 - Column 'company_id' cannot be null
这是junit测试
@Test
public void testsSaveApps() {
List<AppSetting> settings = new ArrayList<AppSetting>();
//int settingid = types.getMaxSettingId()+1;
settings.add(createSettingsOne());
settings.add(createSettingsTwo());
assertEquals(true,types.addTVappsWithSettings( 1,13, "App1", settings, "Danka" ) );
}
private static AppSetting createSettingsOne(){
AppSetting setting = new AppSetting();
setting.setCreated_by("Kasun");
LocalDateTime time = new LocalDateTime();
setting.setCreated_time(time);
setting.setDisplayOrder(1);
setting.setEditable(true);
setting.setSettings_key("url");
setting.setSettings_value("www.google.com");
setting.setUpdated_time(time);
setting.setUpdated_by("Kasun");
//setting.setSettings_id(settingid);
return setting;
}
private static AppSetting createSettingsTwo(){
AppSetting setting = new AppSetting();
setting.setCreated_by("Kasun");
LocalDateTime time = new LocalDateTime();
setting.setCreated_time(time);
setting.setDisplayOrder(2);
setting.setEditable(true);
setting.setSettings_key("url2");
setting.setSettings_value("www.CBC.com");
setting.setUpdated_time(time);
setting.setUpdated_by("Kasun");
//setting.setSettings_id(settingid);
return setting;
}
这是应用程序和设置保存方法
public boolean addTVappsWithSettings(int appTypeId,int companyid, String appName, List<AppSetting> settings, String createdBy) {
//set properties of the app to persist
App app = new App();
//app.setSettings_id(settingid);
// app.setSettings_id(settingid);
app.setApp_id(appTypeId);
app.setCompany_id(companyid);
app.setApp_name(appName);
app.setCreated_by(createdBy);
LocalDateTime created_time = new LocalDateTime();
app.setCreated_time(created_time);
app.setUpdated_by(createdBy);
app.setUpdated_time(created_time);
app.setEnable(true);
app.setapps(settings);
session.save(app);
if (!HibernateUtil.INSTANCE.commitTransaction())
return false;
return true;
}
这些是 DAO 类。
@Entity
@Table(name="company")
public class Company {
@Id //primary key
@GeneratedValue(strategy = GenerationType.IDENTITY)//strategy for generating auto generated number
@Column(name= "company_id", nullable = false)
private int company_id;
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
@Fetch(value = FetchMode.SUBSELECT)
@JoinColumn(name = "company_id", nullable = false)
private List<App> threatviewapps = new ArrayList<App>();
@NotEmpty
@Column(name= "short_name", nullable = false)
private String short_name;
@NotEmpty
@Column(name= "company_description", nullable = false)
private String company_description;
@NotEmpty
@Column(name= "company_name", nullable = false)
private String company_name;
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name= "created_time", nullable = false)
private LocalDateTime created_time;
@Column(name= "created_by", nullable = false)
private String created_by;
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name= "update_time", nullable = false)
private LocalDateTime update_time;
@Column(name= "updated_by", nullable = false)
private String updated_by;
@Column(name= "enable", nullable = false)
private boolean enable;
这是应用程序DAO
@Entity
@Table(name = "apps")
public class App {
@Id // primary key
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "settings_id", insertable = false, updatable = false)
private int settings_id;
@Column(name = "app_id", nullable = false)
private int app_id;
/* @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "settings_id", nullable = false)
private List<AppSetting> tvsettings = new ArrayList<AppSetting>();*/
@ElementCollection
@CollectionTable(name="threatview_app_settings",joinColumns = @JoinColumn(name = "settings_id"))
private List<AppSetting> tvsettings = new ArrayList<AppSetting>();
@Column(name = "company_id", insertable = false, updatable = false)
private int company_id;
@Column(name = "app_name", nullable = false)
private String app_name;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name = "created_time", nullable = false)
private LocalDateTime created_time;
@Column(name = "created_by", nullable = false)
private String created_by;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name = "updated_time", nullable = false)
private LocalDateTime updated_time;
@Column(name = "updated_by", nullable = false)
private String updated_by;
@Column(name = "enable", nullable = false)
private boolean enable;
为什么会出现上述错误?如果你们需要更多信息,请告诉我。
@Entity
@IdClass(SettingIDKey.class)
@Table(name = "app_settings")
public class AppSetting {
@Id
private int settings_id;
@Id
private String settings_key;
@Column(name = "settings_value", nullable = false)
private String settings_value;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name = "created_time", nullable = false)
private LocalDateTime created_time;
@Column(name = "created_by", nullable = false)
private String created_by;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name = "updated_time", nullable = false)
private LocalDateTime updated_time;
@Column(name = "updated_by", nullable = false)
private String updated_by;
@Column(name = "editable", nullable = false)
private boolean editable;
@Column(name = "enable", nullable = false)
private boolean enable;
@Column(name = "display_order", nullable = false)
private int displayOrder;
最佳答案
在您的情况下,您已将 OneToMany 作为 company_id 的拥有方。即,公司类是拥有方。
在这种情况下,插入 App 记录会导致两个查询,一个是插入,一个是更新。首先是插入语句,它在没有 company_id 的情况下执行插入 App 表(因为这不是拥有方),然后它触发更新查询以更新 company_id。因此,要使第一个插入语句成功,它需要 company_id 是数据库中的空字段。否则它会抛出 ConstraintViolationException。
如果您将 ManyToOne 作为拥有方,则会在 App 表中生成单个插入语句。所以在这种情况下 company_id 字段可以为空。
所以有了这个,我看到了两个选择:
Hibernate: values identity_val_local()
Hibernate: insert into Tree (id, "COUNT", FOREST, name, version) values (default, ?, ?, ?, ?)
Hibernate: insert into Tree (id, "COUNT", name, version) values (default, ?, ?, ?)
Hibernate: values identity_val_local()
Hibernate: update Tree set FOREST=?, index=? where id=?
关于java - org.hibernate.exception.ConstraintViolationException : could not execute statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34409159/
什么是 hibernate 和n- hibernate ?我可以在 Visual Studio 2008 中使用它进行 C# Web 应用程序开发吗?请给我建议...我是 asp.net Web 应用
我有一个不系统地发生的异常(exception)。 我试图通过在每次迭代中刷新和清理 session 来解决此问题,但没有成功。 [quartzScheduler_Worker-7] ERROR jd
使用 Hibernate 在数据库中存储 IP 地址的最佳类型是什么? 我虽然是 Byte[] 或 String,但有没有更好的方法,或者你用什么? @Column(name = "range_fr
我正在尝试制定一个公式来选择用户个人资料的用户友好名称。它选择名字 + ' ' + 姓氏 如果其中至少有一个不为空且不为空(包含非空白字符),否则选择 短名称 (条件相同),最后,如果 短名称 为空或
在hibernate中,是否可以将鉴别器作为一个实体?例如,如果我将 Department 作为基类,将 AdminDepartment 和 ProcessingDepartment 作为子类。 De
我只想从表中获取一些列值。因此,我已经使用投影来实现这一目标。该代码有效,但我认为它无效。 我的问题是当我使用ProjectionsList并将标准条件列表设置为ArrayList时-Bulletin
你好: 我对 hibernate 缓存缓存的内容感到困惑。 从文档中,我知道 hibernate 中有缓存类型。 一级 :交易级别。 似乎要被 session 持久化的实体被缓存在这里。 二级缓存 :
我遇到了一个情况: save或update hibernate 的目标表中的某些数据 在目标表上有一个触发器,该触发器将在目标表的insert或update操作之前执行 由 hibernate 将此记
我有一个名为 Master_Info_tbl 的表。它是一个查询表: 这是该表的代码: @Entity @Table(name="MASTER_INFO_T") public class Code
我想知道如何在 Hibernate 查询语言中使用日期文字。我在我的 JPA 项目中做了如下操作(作为 Eclipselink 提供者)并且它工作正常。 SELECT m FROM Me m WHER
@Entity public class Troop { @OneToMany(mappedBy="troop") public Set getSoldiers() { ...
我正在尝试使用 hibernate 查询删除表 'user_role' 中的所有行。但每次我都会出错。有人可以帮我吗。 DaoImpl @Override public void deleteAll(
不是将数据库操作分散在四个 (osgi) 包中,而是在那里做略有不同的事情。我想创建一个负责所有持久性问题的(简单的)OSGi 包。我觉得这并不像听起来那么简单,因为“每个包都有独特的类加载器”。 因
这就是我使用生成器的方式: private Integer id; 我看到的行为是: 创建第一个对象 hibernate 分配 id = 1 删除该对象 关闭服务
对象级别的实体和值类型有什么区别。我知道实体将有一个 id 但值不会,但为什么我们需要不同的方法来映射实体与值类型? 这样做是为了让hibernate可以对值类型应用任何优化吗? 最佳答案 一个实体已
我正在使用 HibernateTemplate.findByCriteria 方法进行一些查询。现在我想在标准上创建一些 SQL 限制,比如 criteria.add(Restrictions.sql
所以我有以下代码: Query query = session.createQuery("from Weather"); List list = query.list();
如何使用Hibernate映射具有多个实体的 View ? 问候, 混沌 最佳答案 请参见Hibernate文档中第5.1.3节“类”,紧接在“Id”节之前: There is no differen
据我所知,Hibernate 有两种类型的实现 JPA的实现(2)(@Entity,@Table注解) 扩展到旧的(传统的) hibernate (没有 JPA),使用 HSQL 查询,没有注释 如果
我需要一个将条目存储为键值对的集合(因此我可以通过键查找值),但我需要一个允许多个值使用 hibernate 共享同一个键的集合 最佳答案 一个键具有多个值的映射称为多映射 - 在 Apache 公共
我是一名优秀的程序员,十分优秀!