It's quite some time that I'm trying to figure out this problem and from googling around many people have similar problems.
I'm trying to model a User in a Social Network, using Hibernate, and what is more basic to a social network than to map a friendship relation?
Every user in the system should have a list of it's friends and I thoug...
Please excuse my ignorance on the topic, as I am relatively new to Hibernate / NHibernate, but I have encountered a mapping I can't figure out:
This is what my database table looks like:
<bincontents>
<id>5873715</id>
<title>Video Title</title>
<sortorder>0</sortorder>
<itemid>23079</itemid>
<itemtype>VIDEO</itemtype>
<...
@Entity
public class A {
@Column(name="Foos")
@Basic
private HashSet<Foo> fooList = new HashSet<Foo>();
}
where class Foo is nothing special, just implements Serializable.
Essentially I want to Serialize the whole HashSet to the database. This mapping works ok to persist, however when I try to load it I receive a ClassNotF...
I have a table in my database looking roughly like this:
create table Foo (
Id int identity not null,
Name varchar(100) not null,
GroupName varchar(100) not null,
constraint PK_Foo primary key (Id)
)
Now I want to map this table into two entity classes like this:
class Foo ...
consider table
sales (id, seller_id, amount, date)
and here is a view that is generated from sales using query SELECT seller_id, SUM(amount) FROM sales GROUP BY seller_id
total_sales (seller_id, amount)
I want to make an entity for total sales but without the view on the sql side.
This entity will be constructed from a query. The ...
Hi,
I am trying to create a dashboard for a homegrown solution that collects native performance related statistics of application servers. Here's the DDL for the data that's been gathered by various agents. I have skipped few columns and non-relevant tables for brevity.
create table server (
id integer not null auto...
I know this should be a pretty elementary issue to fix, but 1) I'm relatively new to Hibernate, and 2) the fixes I've found don't (seem to) apply here.
Here is the exception I am getting:
org.hibernate.MappingException: An association from the table POSTS refers to
an unmapped class: com.beans.User at
org.hibernate.cfg.Configuration...
I have a table called group, that I am trying to map using hibernate for DB2 and HSQLDB. Table name group is a reserved word and it must be quoted in HSQLDB. However DB2 does not like quoted table name.
So this mapping works in HSQLDB but not in DB2:
@Entity
@Table(name="`group`")
public class Group {
Mapping results in following err...
I have a Voucher - POJO mapped to two tables. The first mapping assigns an entity name "voucherA" and maps the POJO to TableA. The second mapping uses "voucherB" as entity name and maps the POJO to TableB.
Now i have also a customer POJO mapped to TableC. This POJO references vouchers in a list.
<list name="vouchers" table="TableC_vouc...
I have a scenario that i want to add some standard properties to my entities. Meaning that i will have e.g. 1 int and 2 string properties applied to all relevant entities. I have over 100 mapping files and most but not all will be hosts to these new properties. In the classes its easy to define this; in the mappings however i've found no...
Dear all,
I have a Hibernate class which is essentially just a wrapper around loads of collections.
So the class is (massively simplified/pseudo) something like:
@Entity
public class MyClass {
@OneToMany
Map1
@OneToMany
Map2
@OneToMany
Map3
AddToMap1();
AddToMap2();
AddToMap3();
RemoveFromMap1()...
I am trying to create a class in HBM file which contains an Enum as a field.
The HBM is similar to this:
<class name="a.b.c.myObject" table="OBJECT" >
<property name="myEnum" column="EXAMPLE" type="a.b.c.myEnum" />
</class>
and let's say that this is the Enum:
public enum myEnum{
a, b, c;
}
The problem is that in the DB...
Is it possible to embed the hibernate mapping hbm.xml’s to the jar and avoid manual reference in applicationContext.xml like
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernatePr...
I experience the following apparently undocumented issue, and I want to understand if
I did something wrong
Did anyone encounter the same issue?
Is it really not documented anywhere? or did I miss something?
The behavior is this
Assume the following mapping
<class name="org.sample.Foo" table="foo">
...
<many-to-one name="bar...
Hi,
I have a problem in Grails 1.1.2 + MySQL.
My domain class Something contains field
Map<String, Map<Integer, Integer>> priceMap
When I run the app, Grails creates table 'something' and sub-table 'something_price_map'. 'something_price_map' contains
BIGINT(20) price_map
VARCHAR(255) price_map_idx
TINYBLOB price_map_elt
The pr...
Assuming the following mappings are provided:
<class name="A" table="a_table">
<id name="id"/>
<many-to-one name="entityB" column="fk_B" not-null="false" unique="true"/>
</class>
<class name="B" table="b_table">
<id name="id"/>
</class>
Java class:
public class A {
private long id;
private B entityB;
// getters and se...
I have a class A which have a list of B elements.
In my A class i would like to add:
int size;
which will be valued with the number of B elements. So when I would call myA.getSize() I will have it.
Is it possible to map a count query with a single property in the hibernate mapping?
I don't want to load the list that is why i woul...
Hi I am trying to Persist a Map in Hibernate as follows:
public class Product{
@OneToMany
@MapKey(name="id")
private Map<Company,ProductCompany> productCompanies=new HashMap<Company,ProductCompany>();
}
public class Company{
private int id;
}
public class ProductCompany(){
@ManyToOne
private Product product;
@ManyToOne
p...
Hi
I try to optimize the database queries in Hibernate, but I found a blocker:
<class name="SupportedLanguageVO" table="AR_SUPPORTED_LANG" >
<cache usage="read-only"/>
<id name="Id" type="java.math.BigInteger">
<column name="ID" sql-type="NUMBER(20)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="Ord...
consider the following class:
class Order {
int OrderId {get; set;}
int CustomerId {get; set;}
string CustomerName {get; set;}
//other fields go here
}
which is mapped to Orders table. Is it possible to map the property CustomerName to the Customers table through the foreign key relation?
...