hibernate-criteria

Hibernate doesn't support accessing fields on usertypes for projection criterias?

流过昼夜 提交于 2019-12-23 20:34:16
问题 My Classes: public class User { @Type(type="AccountType") private AccountType accountType; } public class AccountType { private String name; private AccountType(String name) { this.name = name; } public static AccountType User = new AccountType("User"); public static AccountType Administrator = new AccountType("Administrator"); } I also have a properly setup AccountTypeUserType. My Query: List results = session.createCriteria(User.class) .setProjection(Projections.projectionList() .add

hibernate join two entity in different schema or session

一个人想着一个人 提交于 2019-12-23 19:36:21
问题 I have multiple schemas having their each table. ANIMAL.pet @Entity @Table(schema = "ANIMAL", name = "pet") @JsonIgnoreProperties(ignoreUnknown = true) public class Pet { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "idx") private Integer idx; @Column(name = "name") private String name; } HUMAN.person @Entity @Table(schema = "HUMAN", name = "person") @JsonIgnoreProperties(ignoreUnknown = true) public class Person { @Id @GeneratedValue(strategy = GenerationType

Hibernate Criteria: adding additional restriction to Restrictions.isEmpty

ⅰ亾dé卋堺 提交于 2019-12-22 10:53:53
问题 I have created a Hibernate (3.5) Criteria query: Criteria criteria = db.getSession().createCriteria(Vendor.class); criteria.add(Restrictions.isEmpty("models")); When executed with Criteria.list, Hibernate produces the following SQL (simplified for sake of readability): SELECT this_.* FROM VENDOR this_ left outer join MODEL models1_ ON this_.id = models1_.VENDOR_ID WHERE NOT EXISTS (SELECT 1 FROM MODEL WHERE this_.id = VENDOR_ID) What I'd like to do is add a restriction within the "not exists"

Hibernate criteria with projection not performing query for @OneToMany mapping

邮差的信 提交于 2019-12-22 08:09:35
问题 I have a domain object, Expense, that has a field called initialFields . It's annotated as so: @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, orphanRemoval = true) @JoinTable(blah blah) private final List<Field> initialFields; Now I'm trying to use Projections in order to only pull certain fields for performance reasons, but when doing so the initialFields field is always null. It's the only OneToMany field and the only field I am trying to retrieve with the projection

Hibernate criteria with projection not performing query for @OneToMany mapping

跟風遠走 提交于 2019-12-22 08:09:01
问题 I have a domain object, Expense, that has a field called initialFields . It's annotated as so: @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, orphanRemoval = true) @JoinTable(blah blah) private final List<Field> initialFields; Now I'm trying to use Projections in order to only pull certain fields for performance reasons, but when doing so the initialFields field is always null. It's the only OneToMany field and the only field I am trying to retrieve with the projection

How do I resolve “Unable to resolve attribute [organizationType.id] against path” exception?

怎甘沉沦 提交于 2019-12-21 17:08:06
问题 I'm using Spring 3.1.1.RELEASE, Hibernate 4.1.0.Final, JUnit 4.8, and JPA 2.0 (hibernate-jpa-2.0-api). I'm trying to write a query and search based on fields of member fields. What I mean is I have this entity … @GenericGenerator(name = "uuid-strategy", strategy = "uuid.hex") @Entity @Table(name = "cb_organization", uniqueConstraints = {@UniqueConstraint(columnNames={"organization_id"})}) public class Organization implements Serializable { @Id @NotNull @GeneratedValue(generator = "uuid

Does Hibernate Criteria Api completely protect from SQL Injection

蓝咒 提交于 2019-12-21 04:14:25
问题 I am working with Hibernate to protect my website from SQL Injection. I heard that Hibernate Criteria API is more powerful than HQL. Does Hibernate Criteria Api completely protect from SQL Injection? 回答1: Yes, it does. Criteria API as well as query parameters in HQL or JPQL both escape the parameters and would not execute malicious SQL. The vulnerability is only exposed if you simply concatenate the parameters into your query. Then any malicious SQL becomes part of your query. EDIT The OWASP

Criteria API returns a too small resultset

試著忘記壹切 提交于 2019-12-21 03:34:10
问题 How is this possible, I have to following criteria Criteria criteria = getSession().createCriteria(c); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.add(Restrictions.eq("active",true)); List list = criteria.list(); The size of list is now 20. If I add a max results to the criteria, Criteria criteria = getSession().createCriteria(c); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setMaxResults(90); criteria.add(Restrictions.eq("active",true));

How to join Multiple tables using hibernate criteria where entity relationship is not direct?

大兔子大兔子 提交于 2019-12-21 02:38:22
问题 I have three entities. those are: @Entity public class Organization { @Id private long id; @Column private String name; } @Entity public class Book { @Id private Long id; @Column private String name; @ManyToOne private Organization organization; } @Entity public class Account { @Id private Long id; @Column private String name; @ManyToOne private Book book; } In these three entities I would like to perform following sql: SELECT acc.name, acc.id FROM account acc JOIN book b on acc.book_id = b

Left join using hibernate criteria

一曲冷凌霜 提交于 2019-12-20 11:10:49
问题 I have two entity: Issue and Issue_Tracker . I am using Hibernate 3.6. SELECT `issues`.`issue_id`, `issues`.`issue_raised_date`, `issues`.`issue_description`, `issue_tracker`.`tracker_status` FROM `issues` LEFT JOIN `issue_tracker` ON `issues`.`issue_id` = `issue_tracker`.`issue_id` WHERE `issues`.`status`="Escalate To" How to achieve this using Hibernate Criteria, and most Important, I have to use it for pagination. and My Dao is as follows to show the list of Issues in jqgrid public List