Tag: hibernate

使用DISTINCT关键字导致此错误:不是一个SELECTedexpression式

我有一个这样的查询: SELECT DISTINCT share.rooms FROM Shares share left join share.rooms.buildingAdditions.buildings.buildingInfoses as bi … //where clause omitted ORDER BY share.rooms.floors.floorOrder, share.rooms.roomNumber, share.rooms.firstEffectiveAt, share.shareNumber, share.sharePercent 这会导致以下exception: Caused by: org.hibernate.exception.SQLGrammarException: ORA-01791: not a SELECTed expression 如果我删除DISTINCT关键字,查询运行没有问题。 如果我删除order by子句,查询运行没有问题。 不幸的是,我似乎无法得到没有重复的有序结果集。

我如何使用Maven获取最新的Hibernate版本?

我无法通过Maven依赖关系获取最新版本的Hibernate。 看来最新的我可以从Maven中央仓库获取3.2.6.GA,而且我有兴趣使用3.3.2.GA,它是hibernate.org站点上显示的最新版本。 当我在我的项目的pom.xml中将我的hibernate依赖项修改为最新版本时,我运行Maven构build时出现以下错误: Missing: ———- 1) org.hibernate:hibernate:jar:3.3.2.GA Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -D version=3.3.2.GA -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.hibernate -DartifactId=hibernate -Dve rsion=3.3.2.GA -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[ id] 一旦我这样做,我继续得到错误,指示我需要添加一个javassist依赖项,然后我需要更新我的hibernate-validator依赖项,这也需要本地安装,在那一点上,我停下来,看看周围,看看是否有一个更好的方法,也许可以将Maven指向JBoss […]

删除的对象将被级联重新保存(从关联中删除删除的对象)

我有以下两个实体: 1-播放列表: @OneToMany(fetch = FetchType.EAGER, mappedBy = "playlist", orphanRemoval = true, cascade = CascadeType.ALL) @OrderBy("adOrder") private Set<PlaylistadMap> PlaylistadMaps = new HashSet<PlaylistadMap>(0); 在保存或更新播放列表实体时,需要使用CascadeType.ALL保存和更新PlaylistadMap集合。 orphanRemoval = true :在删除播放列表实体时需要,也应删除PlaylistadMap引用。 2-播放列表地图: @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "fk_playlist", referencedColumnName = "pkid", nullable = false) private Playlist playlist; 当通过使用getCurrentSession().delete();播放列表getCurrentSession().delete(); 我收到以下例外: org.springframework.dao.InvalidDataAccessApiUsageException: deleted object would be re-saved by cascade (remove deleted object […]

@GeneratedValue和@GenericGenerator之间的区别

有时候,我发现他们在一起,有时候是孤单的,有时他们似乎也是这样。 有什么不同? 这里有三个例子。 他们做什么不同? 为什么我不能仅仅使用@GeneratedValue呢? 例1 @Id @GeneratedValue(generator="increment") @GenericGenerator(name="increment", strategy = "increment") Long id; 例2 @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) private int userId; 例3 @ElementCollection @JoinTable(name="Address", joinColumns=@JoinColumn(name="user_id") ) @GenericGenerator(name="hilo-gen", strategy="hilo") @CollectionId(columns = @Column(name="Address_id"), generator = "hilo-gen", type = @Type(type="long")) Collection<Addr> listOfAddresses = new ArrayList<Addr>();

何时使用Hibernate投影?

我对Hibernate的预测和标准有点困惑。 何时使用预测以及何时使用标准? 请帮帮我。 谢谢!

如何从hibernate会话获取jdbc连接?

我想从hibernate session中获得jdbc连接。hibernate session里面有方法ie session.connection(); 但已被弃用。 我知道这仍然工作,但我不想使用不推荐的方法,因为我相信他们必须提供一些替代这个? 在http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/Session.html连接方法API说使用org.hibernate.jdbc.Work为此目的,但我没有find任何这样的例子?

在Oracle列上,HQL“null”和“!= null”

hibernate转换HQL的 column != null column is null SQL中 column is null ?

使用@Query使用hibernate更新spring数据jpa中的布尔值

我有弹簧数据和hibernateconfiguration和运行。 我可以使用spring-data保存logging,但由于某些原因,我无法运行将更新表中所有布尔字段的查询。 我试过这个: @Query("update Content v set v.published = false where v.division = :division and v.section = :section") void unPublishContent(@Param("division") String division, @Param("section") String section); 我也试过这个: @Query("update Content v set v.published = 0 where v.division = :division and v.section = :section") void unPublishContent(@Param("division") String division, @Param("section") String section); 参数分区和部分实现,但没有变化的表格。 ps我也使用mysql数据库。

Hibernate的saveOrUpdate行为

有谁知道Hibernate是如何知道是否INSERT或更新数据库中的一个值,当session.saveOrUpdate()被调用? 到目前为止,我只确定它不依赖于caching中的信息,并且数据库中实体的存在是由主键确定的。

Hibernate EnVers中的@NotAudited和RelationTargetAuditMode.NOT_AUDITED有什么区别?

@NotAudited @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @OneToMany(mappedBy = "booking") @OrderBy("bookingOrder") private List<CustomerBooking> customerBookingList = new LinkedList<CustomerBooking>(); 为什么使用两个? 使用两者还是一个足够好?