This is my persistence.xml:
<persistence>
<persistence-unit name="MyUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/abcDS</jta-data-source>
</persistence-unit>
</persistence>
This is jndi.properties file from src/test/resources which is supposed to create a datasource during testing...
I have a hibernate query which returns 10s of thousands of object results. Is it possible to cycle through chunks of the query rather than handling the entire query at once?
Sample code:
Query q = session.createQuery("FROM Class");
List<Class> classList = (List<Class>) q.list();
Thanks
...
here is my code snippet:
@Stateless
public class mySLSB {
@PersistenceContext(unitName = "db")
private EntityManager myEntityManager;
public void crud(MyEntity myEntity) throws MyException {
myEntityManager.merge(myEntity);
}
}
However this merge can cause a ConstraintViolationException, which does not throw MyException (which i...
Hi,
I have a specific inner join that establishes a join on a PAIR of columns in one join clause. My understanding, that I want to clarify about Hibernate, is that it allows joins only if you give it control of the many-to-one and one-to-many relationships. That's unfortunate, if true, because it sure would be nice to just have hibern...
I would like to make use @IndexColumn to set seq number of some data the user enters. I am using Spring 2.5.6, JBoss 5.1 (JPA 1.0).
For my parent class
@Entity
@Table(name="material")
public class Material implements Serializable {
.
.
/**
* List of material attributes associated with the given material
*/
@OneToMany...
I have a scenario where my application has access to a session for limited time windows, during which it must fetch data from the database into memory, and then only use the in-memory data to serve requests.
The data model is a simple one-to-many association such as:
<class name="com.foo.Road" table="road">
<id name="oid" column="o...
Hi,
I'm trying to use OpenSessionInViewFilter to avoid the infamous lazy loading errors that crop up from time to time. I've spent about a day solid on this, though, but apparently I'm doing something wrong. According to what I can tell from my log files, Spring does indeed report that it's opening a transaction from within the filter. ...
Hi,
I have the following:
@Entity
public class ExamplePhoto {
...
@Column(nullable= false)
private byte[] photo;
...
}
I am using Hibernate and a MySql database. I tried putting a mediumblob but got a "tinyblob expected error" message. Given the fact that the photo could be of up to 400KB the tinyblob won't do the job. How can I m...
Given the following example (departments - projects):
A department has the following properties (composite primary key):
@Entity
@IdClass(DeptId.class)
public class Department
{
@Id
@Column(name="number")
private Integer number;
@Id
@Column(name="country")
private String country;
@Column(name="name")
p...
This is a puzzler! :D
Is there a way to force Hibernate to load a collection for an entity without loading the entire entity first?
Let m explain better. I have a Role entity annotated this way:
@Entity(name="Role")
@Table(name = "ROLES")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@javax.persistence.TableGenerator(
name...
This question is in relation to another question I have asked, but what are the reasons as to why you would use openSession() over getCurrentSession()? I know you would use openSession() so that you could self-manage the closing and flushing of the session, however, why would you want to do this manually?
I have used openSession() when...
Hi,
I need advice how to store model in spring mvc 3 with HIbernate (example on ilustration)
I have model
public class Customer{
int id;
String name;
String surname;
ArrayList<Contact> contacts;
...
getters, setters
}
Here is class Contact
public class Contact{
int id;
String ...
Hi,
Is it correct to say that using JTA Transactions with Hibernate contrasts using the Open-Session-In-View with regards to the session scope?
From what I've been able to gather the Session scope in the JTA Transactions is a transaction (mainly based on this link) while in the Open-Session-In-View pattern the session's scope is the requ...
Suposse I have two classes:
class A {
Set<B> bs
}
class B {
}
This mapping:
<set name="bs" table="bs_tab" cascade = "save-update">
<key column="a_id />
<many-to-many column="b_id" class="B"/>
</set>
And join table like this:
bs_tab(
a_id, b_id, primary key(a_id, b_id)
)
When I add some element to bs set a...
public class Group{
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL, mappedBy="groups")
public Set<User> getUsers() {
if(users == null)
return new HashSet<User>();
else
return users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
public class User{
public void setGroups(Set<Group> groups)...
Hi,
I have a simple app with User, Bid, and Auction, the relationships are clear I hope.
Now I want to implement getWinningAuctionsOfuser( User u ), which would return the auctions which the given user is currently winning.
I know how I would do this in SQL, but I don't have much experience with JP-QL.
What's the best approach?
Curr...
A question of ColdFusion ORM
We are using ColdFusion 9 for the past 6 months and while we've used some of the new features, ORM is something we've avoided because we usually work on the same very large website. Over the years we've used Apache OBJ but then we moved back to CF and used our own DAO objects generated from tables to handle ...