criteria « Map « JPA Q&A





1. Hibernate children count criteria    stackoverflow.com

I have parent/children relationship: newsItem 1-* comment. How can I select a list of newsItems and also count of comments for each newsItem using one Criteria query? I want to do something like ...

2. How to use key of MAP in Criteria Query?    stackoverflow.com

I have a Bean like this

Class TestA
{
    Map<String,TestB> testBMap;
}

Class TestB
{
    String data;
    ...
}
I want to fetch the TestA data along ...

3. @Inheritance TABLE_PER_CLASS criteria strange behavior    stackoverflow.com

In my application I have a mapping like this

@MappedSuperclass
public abstract class Base implements Serializable {

@Entity
@Table(name = "LevelOne")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class LevelOne extends Base {

@Entity
@Table(name = "LevelTwo")
public class LevelTwo extends LevelOne {

@Entity
@Table(name ...

4. Hibernate Query API - criteria on property of a key in map    stackoverflow.com

Let's say I have such model:

public class ProjectModel {
        ...
        private Map<UserModel, ProjectUserRelations> usersRelations = new HashMap<UserModel, ...

5. Hibernate Criteria - how can you limit child classes returned?    stackoverflow.com

I have a very rich hierarchy of entity classes. I'm trying to restrict the results in some queries to only those of a certain list of entity classes. I'm doing the ...

6. Criteria many-to-many query questions, explain createCriteria and createAlias    stackoverflow.com

New at hibernate. Let's say I have the following entities: User and Groups

 @entity(name="user")
 @Table(name="USER")
 public class User {
     @Id
     @Column(name="USER_ID")
   ...

7. How do I create Hibernate criteria when using a many to one mapping    coderanch.com

Assuming my entity class looks something like this snippet: @Entity @Table(name = "USERCASEDETAILS") public class UserCaseDetails implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id @Column(name = "ID") @GeneratedValue(strategy=GenerationType.AUTO) private long id; @ManyToOne(cascade = {CascadeType.ALL}) private User user; @ManyToOne(cascade = {CascadeType.ALL}) private Case caseInfo; @ManyToOne(cascade = {CascadeType.ALL}) private Role role; } Assuming I want to create ...

8. Hibernate criteria in many-to-one mapping.    coderanch.com

I am using criteria to select some records from DB with restrictions on it. I have one table say A & its pojo A.java, its field mapped with other table B. (many-to-one). When i use criteria with restriction, the id (which is the primary key of ) of other class is mapped in the property field. But when i give some ...

9. Using Hibernate Criteria to perform JOIN on a non-mapped col    forum.hibernate.org

THere are 3 tables: UserRole (id, name) LoginUserRole(login_id, user_role_id) UserRolePerm(id, user_role_id, project_id, ...) We need to get a list of user roles for a given user, project. The SQL would be... SELECT login_user_role.user_role_id FROM login_user_role JOIN user_role_permissions ON login_user_role.user_role_id = user_role_permissions.user_role_id WHERE login_id = 1 AND user_role_permissions.project_id = 1 ORDER BY login_user_role.user_role_id How can this be done with Hibernate Criteria API? ...





10. Criteria for children objects    forum.hibernate.org

@ManyToMany(cascade = CascadeType.ALL) @JoinTable(name="eppl_manufacturer_has_eppl_component", joinColumns = { @JoinColumn(name= "eppl_manufacturerID")}, inverseJoinColumns = { @ JoinColumn( name = "eppl_componentID")}) public Set getEpplComponentList() { ...

11. Hibernate multi-directional mapping and the Criteria API    forum.hibernate.org

Newbie Joined: Tue Jan 25, 2011 12:13 pm Posts: 1 I have two mappings that relate to two tables... as follows: Report Request..

12. Criteria Queries in inherited classes    forum.hibernate.org

Hello: I have to retrieve from the DB ,all the products with the following criteria: lasSecciones = GuiSGP.session.find("from Seccion where F_IdSuplemento =" + idProducto + " and A_Habilitado =" + 1 + " and A_BajaLogica =" + 0); Since the relation is bidirectional ,using: ListaSuplementos losSuplementos =new ListaSuplementos(unProducto.getSuplementos()) ; Retrieves all the elements ,does exist a way to retrieve the elements ...

13. Problem using criteria with parent-child relationship    forum.hibernate.org

Author Message mrflippy Post subject: Problem using criteria with parent-child relationship Posted: Tue Feb 03, 2004 1:17 pm Newbie Joined: Tue Feb 03, 2004 12:39 pm Posts: 8 Hello, We have an application that needs to search through records in our database. Everything is working great with Criteria *except* we have a parent-child relationship, and Hibernate doesn't like us ...

14. Criteria API createAlias to a 'map' property type    forum.hibernate.org

Hi, I have a property that is mapped as a 'map' with a String index column and a composite-element. I am trying to use the Criteria API and join onto this mapped column to fetch only rows with a specific mapped index. How do you use the Query API... ie criteria... to join to a property that is a 'map'??? I ...

16. Criteria API and map with entity as key    forum.hibernate.org

I have with a map with an entity as index. Here's an excerpt from mapping: Code: ...





17. Question about the criteria and many-to-one mapping    forum.hibernate.org

Hi ! I've got a sale object wich is composed by a custommer. My mapping look like this : Mapping documents:

18. Mapping query with EXISTS condition with Criteria interface    forum.hibernate.org

Hi, my question is rather simple. I would like to express the following query with the Criteria interface. Is this possible and if yes how ? Code: select * from PE_REQUESTS t1 where NOT EXISTS ( select 1 from PROVISIONING_LOCKS t2 where t2.request_number = t1.request_number ) The only way I see is using a Query ...

19. HQL for criteria involving classes inside Map    forum.hibernate.org

Author Message mosseri Post subject: HQL for criteria involving classes inside Map Posted: Thu May 05, 2005 3:57 pm Newbie Joined: Mon Mar 15, 2004 4:59 pm Posts: 3 I have a POJO Person, with a Map called metaData which contains information about this Person. The map is keyed by a class MetaData and has a value of null ...

20. Example Criteria query with many-to-many mapping    forum.hibernate.org

Hi all, I have a many-to-many mapping and want a Criteria query using the Example class. But I don't know how to formulate the query. I found this posting http://forum.hibernate.org/viewtopic.ph ... y&start=15 which ends with no result. I tried the suggested way in the posting and ended also with a scrambled SQL query. Is there a way to do it? To ...

22. problem with inheritance (discrim.) and criteria -query    forum.hibernate.org

Newbie Joined: Mon Nov 28, 2005 12:07 pm Posts: 17 Hallo you experts :) I could use some help: The DB design is: a person can be a student or a lecturer. both are unitied in one table with a discriminator. Both have a CourseStudy, of course in a different role. So both classes have their own man-to-one relation. (btw, the ...

23. Criteria and Joined Inheritance    forum.hibernate.org

I try this : Criteria criteria = session.createCriteria(AbstractClass.class); criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY); return criteria.uniqueResult(); where @Inheritance(strategy = InheritanceType.JOINED) abstract class AbstractClass ... @Entity class ConcretA extends AbstractClass { ... } @Entity class ConcretB extends AbstractClass { ... } but the criteria query return a proxy of AbstractClass, not a ConcretA or ConcretB instance. Why ?

24. Using Criteria Query on Mapped Assosiations    forum.hibernate.org

I am getting an exception when i try to execute the below code. Criteri cq = session.createCriteria(ShopDTO.class); cq.add(Restrictions.eq("productDTO.ID", productCode.toString())); //ID is the PK of product// cq.add(Restrictions.eq("productDTO.productAbbreviated", productAbbr.toString())); cq.list(); The above code works if i comment the Restrictions.eq("productDTO.productAbbreviated", ..... part This is the stack trace org.hibernate.QueryException: could not resolve property: productDTO.productAbbreviated of: ShopDTO at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43) at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:63) at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31) at org.hibernate.persister.entity.BasicEntityPersister.toColumns(BasicEntityPersister.java:1086) at ...

26. Criteria/Query bY example supports inheritance?    forum.hibernate.org

public List findByExample(Object exampleInstance) { System.err.println("Creating criteria for class " + exampleInstance.getClass().getName()); Criteria crit = getSession().createCriteria(exampleInstance.getClass()); Example example = Example.create(exampleInstance); crit.add(example); ...

27. Incomplete children collection with a Disjunction criteria    forum.hibernate.org

Hello The hibernate version I use is : 3.2.1. I have a problem when I perform a criteria which contains OR restrictions on a collection. The root object I retrieved has its collection of children objects incomplete. Only the children which correspond to the OR restrictions are in the collection but the other not. Let's take the following example. The class ...

28. accessing keys with criteria    forum.hibernate.org

29. CRITERIA QUERY FOR CHILD Collection    forum.hibernate.org

I am new to hibernate. I have one to many relationship select a.*, b.* from A a, B b where a.id = b.id and a.name = "rus%" and b.list in (22, 3,3,4); I am using Query by example partially in follwoing criteria Created example for A, and B, where instance ==A and instance.getBs == Collection B object Criteria c = getSession().createCriteria("A"); ...

30. Problem using EntityMode.MAP, Criteria and ProjectionList    forum.hibernate.org

Hibernate version: 3.2 Mapping documents: Code between sessionFactory.openSession() and session.close(): I only ...

31. How to map collections using arbitrary join criteria?    forum.hibernate.org

Hibernate version: 3.3 I think this is an easy one guys. I don't know why I can't figure it out. But I have a requirement to create some collections where a primary key is not involved. I'll give two examples... [Dog] - id - name - breed - shows (how to relate Dog.breed -> DogShow.breed ?) [DogShow] - id - showType ...

32. Query Criteria - Restrict child results in one-to-many    forum.hibernate.org

I don't want to jump on a dead thread but I ran into this and could not find much about it. So this might help others down the track. Maybe this will make a difference for you: createAlias("propertyAudits", "pa", CriteriaSpecification.LEFT_JOIN); Don't ask me why it just seems to work for a similar Criteria I am doing. And it will not work ...

33. Criteria API and Inheritance    forum.hibernate.org

Hello, I'm quite new to hibernate so sorry for maybe dump question. Is it possible to use Hibernate's criteria API on inherited classes? Inheritance strategy is Table per subclass. To more narrow I need to use Criteria API on non inherited properties. BaseClass { baseProp; } InhAClass extends BaseClass { inhAProp; } InhBClass extends BaseClass { inhyBProp; } EncapsulClass { baseClass; ...

34. joining tables without mapping with criteria... possible?    forum.hibernate.org

Hi. i dont know if there is already an answer for this but it is really urgent i have 2 tables, one is my person table and other is my view_log table i need to get last few viewers of a site/article etc. and my query needs to be like: select p.* from persons p join view_log v on p.id = ...

35. Using criteria with mapping, constraining on typ    forum.hibernate.org

I read the version 3 documentation and did not see any explanation for the best way to use the mapping in a Criteria. I want to constrain the join to a particular type of the . A quick example to demonstrate (similar to the one in the documentation): ... ...