-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Envers: how to handle nested properties?
PostPosted: Mon Oct 27, 2014 11:25 am 
Newbie

Joined: Mon Jan 13, 2014 10:17 am
Posts: 5
Hi,

i'm a bit stuck and i searched a while now, not finding an answer.

I' tring to find something like this:
lets say we have products and manufactures.

My Product class has got a property Manufacturer:

Code:
@Entity
@Audited
@Table
public class Product {
 
  private int id;
  private String name;
  private Manufacturer manufacturer;

  @Id
  public int getId() { return this.id; }

  @ManyToOne
  @JoinColumn(name = "MANUFACTOR_ID")
  public Manufacturer getManufacturer() { return this.manufacturer; }

  @Column
  getName()...

}

@Entity
@Audited
@Table
public class Manufacturer {
 
  private int id;
  private String name;
  private Set<Product> products = new HashSet<>(0);

  @Id
  public int getId() { return this.id; }

  @OneToMany(mappedBy = "manufacturer")
  public getProducts() { return this.products; }

  @Column
  getName()...

}


i want to get all products where manufacurer name like "acme"

I've tried this but it didn't work:

AuditReader ar = AuditReaderFactory.get(session);
AuditQuery query = ar.createQuery().forEntitiesAtRevision(Product.class, 5L);
query.add(AuditEntity.property("manufacturer.name").ilike("acme", MatchMode.ANYWHERE));


Quote:
could not resolve property: manufacturer of: my.path.Product_AUD


Note this is just a sample to understand my problem. I can't provide original classes. If there are typing errors ist because i coded this example in this editor here.
so basicly i want to check a nested property.

Maybe this is not the correct way, so im asking for the correct way to query products where manufacturer name is like "acme"...

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.