I have a Hibernate entity, with a getter that is mapped as a @OneToMany:
@Entity
class Parent extends BaseParent {
@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "parent")
public List<Child> getChildren() {
return super.children;
}
public void setChildren(List<Child> list) {
super.children = list;
...
I have a hibernate query in grails
Book.findAllByRating(4)
In the above query i want only 5 number of outputs.How do I limit the output to 5?
...
I have a class User object. I am trying to load this object from the Database using Hibernate.
My SQL statement is:
SELECT
users.uid AS uid,
users.deleted AS deleted,
users.username AS username,
users.passwd AS passwd,
users.disabled AS disabled,
users.lockout AS lockout,
users.expires AS expires,
data_first...
I'm trying to do pagination with Hibernate using setFirstResult() and setMaxResults() but I'm not getting the expected results when setting the first result to 0.
When doing the following:
Query query = session.createQuery(queryString);
query.setFirstResult(0);
query.setMaxResults(30);
List list = query.list(); //list.size() r...
It's a long one! ;-)
There are a lot of copy pasted text in this question which makes it look
complicated. And to be honest, it's a lot of information! However to an experienced person a lot of it might be unnecessary and easy to skim over.
In its essence I'm only wondering why my basic Hibernate Core +
Hibernate Annotations test proje...
If I want to specify some nonclustered indices in a hibernate mapping as follows:
CREATE NONCLUSTERED INDEX [Index_name] ON [dbo].[Individual]
(
[ID] ASC,
[IsActive] ASC
)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]
what's the best way to do it for multiple tables that a...
I'm learning Grails/GORM and as I've understood it the current best practice is not to store domain objects in the session (see http://jira.codehaus.org/browse/GRAILS-978 for a potential fix).
The workaround is simple; simply store the reference id for the domain object in the session, and then re-retrieve the object using on the next r...
Can I use HQL to get the index of an ordered query result?
The only way I know to do this is to get back all of the results from the database, then iterate through all of the results.
For example, given:
<hibernate-mapping>
<class name="Dog" table="DOG">
<id name="id" type="int" column="DOG_id">
<meta attribute="scope-set">protec...
I'm looking for an editor that has the help from
http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html
built in, and allows simple editing of the XML files in a GUI fashion. I realise there's CodeSmith and MyGeneration, but from what I remember these only go one way, and don't allow editing existing HBM files.
...
Just trying to get my head round Spring and figuring out how I wire up an Oracle connection in xml config file, and now find out I need yet another framework! - Hibernate, this is soooo frustrating as it feels like I'm getting deeper and deeper into more and more frameworks without actually getting what I need done!
I looked at Hibernat...
I'm familiar with ORM as a concept, and I've even used nHibernate several years ago for a .NET project; however, I haven't kept up with the topic of ORM in Java and haven't had a chance to use any of these tools.
But, now I may have the chance to begin to use some ORM tools for one of our applications, in an attempt to move away from a ...
I need a quick jump start for using Spring and Hibernate together and I was looking for some sample code to modify and extend. Bonus points for Struts2 and Spring Security integration.
...
Hi, I'm thinking about using the Open Session In View (OSIV) filter or interceptor that comes with Spring, as it seems like a convenient way for me as a developer. If that's what you recommend, do you recommend using a filter or an interceptor and why?
I'm also wondering how it will mix with HibernateTemplate and if I will lose the abil...
Req.hbm.xml:
<id name="reqId" type="long" column="REQ_ID">
<generator class="sequence">
<param name="sequence">SEQUENCE</param>
</generator>
</id>
<bag name="lines" lazy="false" >
<key column="REQ_ID" not-null="true" />
<one-to-many class="com.Lines" />
</bag>
Lines.hbm.xml
<id name="lineId" type="...
I have a complicated HQL query.
I would like to access the Oracle specific rownum column value as part of my returned results. How do I write my query (and/or change my hbm.xml) to support this?
What I have tried so far does not work:
modifying my hbm.xml
<property name="rownum" type="int" update="false" insert="false" generated="ne...
I'm running into a performance problem in my SQL using Hibernate's DetachedCriteria. I have a few many-to-one relationships and when Hibernate generates the SQL it's including all of the fields from the tables that are joined in the FROM.
When this happens, it's taking MySQL a long time to run the query (which also has an order by and su...
HQL queries are converted to SQL.
I would like my program to have the complete SQL string before it is sent to my database.
Can I do this?
Notes:
I can see the SQL sent to the database by setting
<property name="hibernate.show_sql">true</property>
in my cfg.xml
...
I have JPA entity (Object A) with a One-Many owning relationship (Object B) in an ArrayList.
I want to be able to query (either Hibernate or JPA) for Object A without having any of the instances of association Object B returned (no proxies or otherwise) in the One-Many ArrayList.
Ideally the returned ArrayList would be null or empty.
...
This is a problem I keep on running into:
I would like to have hibernate manage a single table that represents a collection of collections. For example:
a Map of Maps
List of Sets
Map of Lists
Example, I would like to be able to represent this:
class OwningClass {
Long entityId;
Map<String, List<Element>> mapOfLists;
}...
How can I store logical expressions using a RDBMS?
I tag objects and would like to be able to build truth statements based on those tags. (These might be considered as virtual tags.)
Tags
new
for_sale
used
offer
Rule
second_hand_goods = (!new or used) and for_sale
new_offer = new and offer
second_hand_offer = second_hand_goods and of...