Sorry to bother - perhaps this is a very simple question - but for some reason the version below fails to get parsed, whereas the version with set works fine. In fact, if I just take the set version and replace set with list I get:
nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid m...
I have project creating with WPF and for database O/RM using LINQ to SQL, when i finish my project some people want to use MySQL as database, so can I change my Linq to MySQL without change any source code (maybe just change the connection string)
Regards
...
Hi,
I have an entity, a Group, which has User objects inside it. On creation of a User, that User is added to a Group. This is done through an API, so the flow of control is roughly:
Complete web form for new user, submit
Hibernate creates new user, adds user to group
Website requests group and list of users
Hibernate loads and return...
I have something like Person, and Address object(Person has an Address and other properties).
I update Address or other properties in one request. And in another request I'm searching through all persons. But sometimes I can see properties modified and sometimes I cannot.
Just making another request will return me either modified or u...
When using Blob-fields in n-to-m-relations Hibernate and MSSQL are failing for some reason.
SQL Error: 421, SQLState: S0001
The image data type cannot be selected as DISTINCT because it is not comparable.
...
could not initialize a collection: [Dataset.documents#someID]
My classes look as follows:
@Entity
class Dataset {
@OneToMa...
In this code how to generate a Java class for composite key (how to composite key in hibernate):
create table Time (
levelStation int(15) not null,
src varchar(100) not null,
dst varchar(100) not null,
distance int(15) not null,
price int(15) not null,
confPathID int(15) not null,
...
I'm having problem on JPA (Hibernate) Fetch Join :
Here is my JPQL query
SELECT n FROM News n LEFT JOIN FETCH n.profiles AS pr WHERE pr.id=?1
But it's not working. How can I make a query that filters on the list that is being fetched ?
...
I'm encountering somewhat of an, uh, unorthodox design and I'm not quite sure how to handle it. The table I'm trying to map looks like:
TABLE example {
ID INT,
CATEGORY VARCHAR,
PROPERTY VARCHAR,
VALUE VARCHAR);
A single id can have several rows (obviously, not a primary key). As an example, it could look like:
# ID ...
here is the config file for mysql
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.connection.username">root</property>
<property na...
I want to have a column for an entity which only accepts one of an enumerated set of values. For example let's say I have a POJO/entity class "Pet" with a String column "petType". I want petType to only allow one of three values: "cat", "dog", or "gorilla". How would I go about annotating the getPetType() method in order to have a dat...
Is this really all that I have to do to achieve session per request with Ninject?
public class WebModule : NinjectModule
{
public override void Load()
{
Bind<ISession>().ToMethod(x => MvcApplication.SessionFactory.OpenSession()).InRequestScope();
}
}
Global.asax:
public class MvcApplication...
I am not suggesting that all models are tables.
What I am asking is whether every single table must also have its own class defined specifically for it when using Zend? Is there any way of getting away from this awkward boiler-plate coding. We're just starting to look into Zend (hoping to leave procedural PHP land!) and my colleague thi...
If you have two repositories dealing with persistance to a relational DB, a personrepository that deals with "Person" objects, and an addressrepository which deals with "Address" objects, and a person object has a collection of addresses (probably lazy loaded). Obviously the personrepository would be used to persist changes to the person...
I am new to Hibernate and JPA, and am having difficulty setting up a composite key, as defined below:
@Entity
@Table(name = Entity.TABLE)
@IdClass(EntityPK.class)
public class MyEntity extends Entity {
@CollectionOfElements
@JoinTable(name="items",
joinColumns = @JoinColumn(name="items"))
private ...
We develop and support and application that uses Hibernate as an Object-Relational Mapping tool to persist our Java objects into the database. Unfortunately, there have been some changes in object model, and thus the database schema, between OurApp 1.0 and OurApp 2.0. So, we would like to write an automated tool to migrate the data from ...
Hi
I m using JPA to insert a row
My update code as in here
Now i m inserting a row using this code
public void get_image (String id)
{
Object l = null;
try
{
em = this.getEm();
EntityTransaction entr = em.getTransaction();
entr.begin();
newa.Options o = new newa.Options();
newa....
I currently am trying to persist a collection using @OneToMany(cascade=CascadeType.ALL) for a simple list of objects. The table for Parent_Child gets created in MySQL but the keys for each object are not updated upon using SaveOrUpdate. Any idea what the issue is? (My parent key is defined and the children are generated). I add the child...
Everything I read about Hibernate states that you must roll back a transaction and close the session when an error occurs, and there's usually some variation of the following code (taken from Hibernate's docs) given as an example:
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
//...
I have two entities: Project, Employee
Employee has primary key {employeeId} + some other attributes
Project has primary key {projectId}
Code:
public class Employee {
Long employeeId;
String name;
}
public class Project {
Long projectId;
Collection<Employee> employees;
}
Employee and Project is a one way many-to-many ...
Two classes:
<class name="SpreadsheetImportTemplate" table="spreadsheetimport_template">
<id name="id" type="int" column="id" unsaved-value="0">
<generator class="native" />
</id>
<property name="name" type="java.lang.String" column="name" not-null="true" length="100" />
<many-to-one name="creator" class="org.openmrs.U...