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: Is it possible in JPA/Hibernate?
PostPosted: Tue Jul 06, 2010 5:50 am 
Newbie

Joined: Tue Jul 06, 2010 4:16 am
Posts: 1
Hi,

this my problem: I have a object with text templates: id, name and byte[] in BLOB. The templates are used in several other objects. My need is to know whether the template is used by other objects. Is it possible to bind a not persistent field with JPQL/HQL query, which check a occurrence of the template? Use case, e.g., if the template is used, the delete operation of template is prohibited.

E.g.

@Entity(name = "TEMPLATE")
public class Template {

@Id
private long id;

@Column(name = "NAME")
private String name;

@Lob
@Column(name = "TEXT")
private byte[] text;

@not-know-annotation(query = "SELECT... which returns number of the occurrence of the template")
private long counter;

... simple setters and getters...
}

and later in a other code:

if (template.getCounter > 0) {
disableDelete();
}

Is it possible?

Regards,
Jacek


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.