I have a problem with entity versioning. Here's what I want to archive:
Let's say that I have entity class A (POJO with javax.persistance.* annotations). It's in relations with other entities. Then I need to insert new version of A. All rows should still reffer to old one, but it should be marked as archived and new version should be in...
I am trying to establish a relationship between 2 entities which would be zero-to-one. That is, the Parent can be saved without the associated Child entity and also along with the assoicated Child.
Following are the 2 Entity classes...
Employee (Parent)
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.AUT...
Hi all!
I'm using an extended persistence context (injected Entitymanager at SFSB) and have additionally set @TransactionManagement(value=TransactionManagementType.BEAN) for the SFSB to have full control over the UserTransaction.
The Transaction is controlled on client side where I start a lookup for the SFSBs containing a reference to...
Hi there,
I've got some byte[] fields in my entities, e.g.:
@Entity
public class ServicePicture implements Serializable {
private static final long serialVersionUID = 2877629751219730559L;
// seam-gen attributes (you should probably edit these)
@Id
@GeneratedValue
private Long id;
private String description;
...
Env: Spring 2.5.6, Hibernate 3.3.2, Ehcache 2.0.1, terracotta 3.2.1
I have a cache on an abstract class (with 5 inheritors)
<cache name="com.f4.owl.domain.good.GoodType"
maxElementsInMemory="15000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false">
<terracotta/>
</...
I am using Hibernate entity manager 3.5.1-Final with MS SQL Server 2005 and trying to persist multiple new entities. My entity is annotationally configured thus:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
After calling
entityManager.persist(newEntity)
I do not see the generatedId set, it remains as 0. ...
I want to make sure that all rows in my table have a unique combination of two fields, and I want to specify this using annotations in my entity class. I have tried using a combination of @Table and @UniqueConstraint but apparently I'm doing it wrong, in that I can only seem to specify that the separate columns should be unique (I can a...
I am working on a project that is in transition from proof-of-concept to something worthy of a pilot project. One of the key improvements for this phase of development is to move away from the current "persistence" mechanism, which uses a hash table held in memory and periodically dumped to a file, to a more traditional database back-end...
I am pretty new to Hibernate / Java (JSF 2.0) and I am attempting to call a custom query and read the results into an object that I have created Logins. Logins has two setter functions, setLoginDate(Date date) and setUserId(Integer userId) my function looks like so, The issue I am having is how to transform the result set and read in th...
When run against and Oracle database, what is the runtime type of the object that the following Spring Hibernate Template (Spring 2.5 and Hibernate 3.3.2GA) code returns where the SQL query is a counting query like select count(*) from table?
String sql = "select count(*) from table";
BigDecimal count = (BigDecimal) hibernateTemplate....
I would like to implement inheritance in Hibernate.
in the database:
object table is:
CREATE TABLE `object` (
`id` bigint(11) NOT NULL auto_increment,
PRIMARY KEY (`id`),
)
code_table table is:
-
CREATE TABLE `code_table` (
`id` bigint(11) NOT NULL auto_increment,
`description` varchar(45) character set latin1 default ...
I am looking for a way to inject certain properties via Spring in a bean that is loaded from the DB by Hibernate.
E.g.
class Student {
int id; //loaded from DB
String name; //loaded from DB
int injectedProperty; //Inject via Spring
}
Can I configure Spring so that whenever Hibernate creates objects of class Student, some pro...
MyObject myObject = repositoryHibernateImpl.getMyObjectFromDatabase();
//transaction is finished, and no, there is not an option to reopen it
ThirdPartyUtility.doStuffWithMyObjectType( myObject );
at this point you've already defined what is lazy and eager loaded, and the third party utility will try to call all of the methods on your ...
I'm currently stuck with what seems to be a very simple problem, but I just can't seem to find a way around:
I have 2 identical tables:
tbl_creditcard_approved_txns
tbl_creditcard_declined_txns
The fields in both are identical, and I have one class - Transaction that is used to represent all the appropriate fields in the tab...
class Mstatkey
// This defines the coomposite key over the columns deviceid, groupaddr, srcaddr
@Embeddable
public final class MstatKey implements Serializable {
private Integer associatedNetDeviceId;
private Long groupAddr;
private Long sourceAddr;
....
// Here we use the composite key
class Mstat
@NamedQuery( ...
Here's the domain classes I'm working with:
class Foo {
String name,
type
static hasMany = [ bars: Bar ]
List bars
static mapping = {
bars lazy:false
}
}
class Bar {
String value
static belongsTo = Foo
}
I've written some Criteria queries in order to give the users an interface to que...
I have a property of a business object which is calculated. The calculation involves some of the logged in user's details, and so can't be represented as a simple SQL query.
I'm having trouble representing the field in the Hibernate mapping XML file, because Hibernate continues to try and retrieve the field from the database, although ...
What is the correct way to write this JPA query? I am just guessing as I cant work it out or find it in my JPA book.
Query query=em.createQuery("select m from Meeting m where count(m.attendees) = 0");
return query.getResultList();
I am currently trying this with Hibernate and I get a mysql error!
ERROR org.hibernate.util.JDBCExceptio...
I have 4 persistent classes which all have the same fields (exactly) the only 3 difference between them is 1) the class name, 2) the table name and 3) the data. i am aware that this might seem strange to some but trust me there is a good reason which i won't go into here.
now, i'm using hibernate annotations to configure my class which ...
i am facing these exception:
1515 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: -1, SQLState: XJ040
1515 [main] ERROR org.hibernate.util.JDBCExceptionReporter - DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040, SQLERRMC: Failed to start database 'myeclipse', see the next exception for details.
java.sql.SQLException:...