I am writing a GWT application, using Hibernate at the server side. Right now, I am entirely confused about the correct way to transfer my objects to the client side of the GWT application in the least amount of code. I am using Gilead to avoid having to double the amount of classes in my domain model [1].
First off, my question is how ...
Hi!
I have some class C that contains Map<A, Set<B>>, where A and B has long id and mapped in tables a and b. I want do some mapping of C into table with 2 attributes a_id and b_id. How can I do it?
Thanks.
...
Is it possible to output the resulting hbm file for a class if you are trying to debug a problem?
Are there any tools that can take a hbm and convert it to annotations? or visa versa
...
How can I access the Hibernate mapping of my model to find out the column name of a property?
The column name is not specified in the mapping so Hibernate generates it automatically - I would like to create a native SQL statement including this column name.
...
When you run a JPQL update or delete query, is Hibernate smart enough to invalidate the 2nd-level cache for the entity that is changed?
Contrived example:
You have the JPQL:
update Product p set p.status = 'S' where p.name like 'Monitor%'
If you currently have products in the 2nd-level cache when that statement is run, will Hibernat...
Hi all,
I can't delete a child object from the database. From the org.apache.struts.action.Action.execute() method, I am removing the child from the parent's List, and also calling session.delete(child). I've simplified the code below and only included what I believe to be relavent.
Hibernate Mapping
<class
name="xxx.xxx.hiber...
I have a Hibernate class called Expression (simplified here for your viewing pleasure):
@Entity
public class Expression {
@Id
@GeneratedValue
private long id;
private String data;
@OneToMany(fetch=FetchType.EAGER)
@Cascade({CascadeType.MERGE, CascadeType.PERSIST})
private Set<Expression> dependencies;
}
T...
Trying to get all articles, with unique titles (distinct(title)), that have a body of "".
List<Article> articles = (List<Article>) session.createQuery("select distinct a.title from Article a where body = :body")
.setString("body", "")
.list();
I am getting the error:
main java.lang.ClassCastException: java.lang.String cannot be cast ...
Hi all,
I'm using hibernate for all DB operations.
My problem is that, I want to insert an string in table which contains ' e.g. rea9'ea/rea9'ea.
While inserting it I'm getting the following exception
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that c...
I want to get a distinct result based on a property, but return the id in the select because I will be using it in a subquery.
e.g.
(List<Article>) session.createQuery("from Article a where a.id in (select distinct a2.title from article a2 where a2.body = :body");
setString("body", "")
.list();
The key section is the subquery, I want...
I got an application running in a jboss container using hibernate. However I'm having trouble with the logging that hibernate is doing. I get these startup messages when Hibernate initialises:
2010-01-08 17:23:42,017 INFO [Configuration:1403] - Configuration resource: /hibernate.cfg.xml
2010-01-08 17:23:42,070 INFO [Configuration:1541...
A many-to-many relationship.
The tables:
Product (productId, ...)
Category (categoryId, ...)
Product_Category(productId, categoryId)
I setup the relationship so all updates will be done via the Product entity.
Product Entity:
private Set<Category> categories = new HashSet<Category>();
public void AddCategory(Category catego...
My question is related to Transactions and Exceptions
Requirements:
I have 10 records to insert into database table. And after inserting every record, I insert data into another table. So if inserting to second table fails, I want to rollback that record.
Ex.
Say handle cash transfer (from one account to account) for 10 persons at a t...
I am doing this in each and every DAL method:
public static Product GetProductByPartNumber(String partNumber)
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Product product = (Product)session.createCriteria(Product.class)
...
I solved my problem, but I just want to get a better understanding of how things are working.
I am looping through a collection, creating/initializing a new Product, adding a category it its collection (mapped m:m) and then saving and commiting the transaction.
for(Blah b : blahs)
{
session = getcurrensession();
Product p = new Pr...
I am trying to run hibernate on a PostgreSQL 8.4.2 DB. Whenever I try to run a simple java code like:
List<User> users = service.findAllUsers();
I get the following error:
PSQLException: ERROR: relation "TABLE_NAME" does not exist
Since I have option hibernate.show_sql option set to true, I can see that hibernate is trying to run ...
I am working on a API to access data stored in a system. The system contains things like people, appointments and procedures associated with those appointments. My application will strictly be read-only.
I am using Spring w/ RowMapper to build objects such a "Person", "Appointment" and "Procedure". I have a DAO for each element. (ie: P...
I have a Criteria-Query, which joins a second table B, to select entities from table A. The problem is, that this query returns some entities from table A multiple times. But I need the results to be distinct.
Using Criteria.DISTINCT_ROOT_ENTITY is useless, becaus this filters out the multiple occurences after the SQL-Query was execute...
Guys do u have any idea about unions in hibernate.
I got this question in a interview .My guess is yes but not sure where and when
...
if hibernate can generate the db schema, how to tell it to create a column of nvarchar(max) in a sql server db?
what tools are available to go the other way around, i.e. a tool that reads the database schema and outputs POJO's with annotations?
...