persistence

JPA: Problem with persisting Foreign Key Constraint

I got two Entity: Customer Entity @Entity public class Customer { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @OneToMany(mappedBy="customer", cascade=CascadeType.ALL) private List<Facility> facilities; //Setter and Getter for name and facilities public void addFacility(Facility facil...

In Ruby on Rails how can I persist objects in memory between sessions

I'm trying to build something (ultimately a gem but for now an application) that works as follows. Suppose for example the DB records are breeds of dog. There's a Dog parent class and a child class for each breed. The actual breeds aren't known until runtime. When the server begins it will load up records from the DB and instantiate ...

DiscriminatorColumn is a foreign key

Hi all, Recently I've been considering using the DiscriminatorColumn approach to achieve entity inheritance. Eventually I've rejected this idea, because the positives from it would have been insignificant and they wouldn't have paid off. One question still bothers me though. It comes up from the following situation. Let's say that we...

Should I use Hibernate with this multi-threaded architecture or abandon it?

My software uses multiple threads to do its work. There is a pipeline that looks something like this: +-----------------+ |+-----------------+ +------------+ ||+-----------------+ +------------+ | | ||| | | | | Get and | ||| Worker Threa...

Fluent NHibernate has many mapping where child table has not primary key

So I'm a couple of weeks into NHibernate so pleae bear with me. I am working on a legacy database with lots of weird issues. I have a name object public class Name { public Name() { Addresses = new List<Address>(); } public virtual string Id { get; set; } public virtual str...

how to use new scala 2.8.0 nested annotations

Hi folks, looks like when scala 2.8.0 is out, we can use nested @annotations in our persistence layers. But how? Can anyone please transform this from java to scala? Thanks. @NamedQueries({ @NamedQuery(name = "findAll", query="select p from Person p"), @NamedQuery(name = "findTheOne", query="select p from Person p where...

Entity Manager / persistance file structure

hi all, The title isnt clear as i couldnt think of one but, i have an EJB project and am trying to play with JPA. To create the entity manager i am injecting it in via anotations @PersistenceContext(unitName="testConnection") private EntityManager em; when i run a test qurey which i belive to be fine Query userQuery = em.cr...

Is it bad practice to use DiscriminatorFormula for migration of Hibernate databases?

I have an application using Hibernate for data persistence, with Spring on top (for good measure). Until recently, there was one persistent class in the application, A: @Entity public class A { @Id @Column(unique = true, nullable = false, updatable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; ...

Is it possible to write custom SQL in OrmLite?

Hello. I have a class which I want to persist with OrmLite and it stores most of its data in a HashMap. I want to map these fields to the table in Sqlite, leaving the ones absent in the map as null. Is it possible to override methods to save some record to the database with custom implementations using OrmLite? ...

when is an EJB CMP entity bean actually created

Hello, I have a session bean that provides a business method, in which it creates several CMP entity beans, something like this public void businessMethod(int number) { try { MyBeanHome home = lookupMyBean(); DataSource dataSource = getMyDataSource(); Statement statement = dataSource.getConnection().createSta...

Are there any relatively mature RDF/OWL Persistence Frameworks I can use?

I have looked at Elmo from openrdf.org, but it doesn't seem to support having object within another object. E.g. Class Roof within the Class House and then allow persisting House object. Is there any other fairly mature and better documented persistence framework out there for RDF/OWL data that will allow such operations? Or if not, i...

eclipselink doesn't fetch list

Hi, there are two entity classes: @Entity public class Place implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToMany(mappedBy = "place") private List<Event> events = new ArrayList<Event>(); private String name; //getters setters } @Entity public class Event implements...

Hibernate, Persistence and @OneToMany and @ManyToOne annotations problems

Hello, I have some problem with @OneToMany and @ManyToOne annotations. I have two class Suite and SuiteVersion. A SuiteVersion is dependent of a suite. So i have implemented this in my code: Class Suite : @OneToMany(mappedBy = "suite") @Cascade(CascadeType.DELETE_ORPHAN) private List<SuiteVersion> listSuiteVersion = new ArrayList<Sui...

Apache OJB: How can I change the eager / explicit / lazy loading behaviour at runtime?

Hi, we use Apache OJB for persistence. Usually we use the proxy mechanism to have a lazy loading behaviour of 1:n relationships. The proxy mechanism is defined in the repository definition file. Now we have one special situation in that I want to force OJB to load all related objects at once, immediately. I.e. this query: Collectio...

Why I have to redefine data stucture twice? should I?

Choosing carefuly datatypes, finally a complex Class is created, then using a HashMap, those first Class objects get mapped with a key. and now I can create thousands and access them, add, delete, etc.. Now if I want to store them in a DB.. So I start from scratch? have to create the table?, again take care about datatypes? to make fit...

How can I override deserialization in C#

I've got a class that will undergo certain version changes over the course of time. The data from inside this class is serialized and deserialized as part of the startup of my application. The problem I have is if I update the class by adding more properties, and then start the application, the old data does not get loaded properly. What...

Java: Google App Engine JDO objects don't update

I am getting an object from the Datastore using JDO and the PersistenceManager using some methods I have built. String email = request.getParameter("email"); MyUser user = MyUser.all(myPersistentManager).filter("email", email).get(); this gets me the user with the given email address that was persisted during another session. It works...

Object persistence terminology: 'repository' vs. 'store' vs. 'context' vs. 'retriever' vs. (...)

I'm not sure how to name data store classes when designing a program's data access layer (DAL). (By data store class, I mean a class that is responsible to read a persisted object into memory, or to persist an in-memory object.) It seems reasonable to name a data store class according to two things: what kinds of objects it handles; ...

Hibernate, Persistance and delation of associations.

Hello, I have some problem with delation of associations, this is my code : Classe ModuleVersion @ManyToMany(mappedBy="listModuleVersions") private List<SuiteVersion> suiteVersions = new ArrayList<SuiteVersion>(); Classe SuiteVersion @ManyToMany() private List<ModuleVersion> listModuleVersions = new ArrayList<ModuleVersion>...

Entity versioning in JPA + Hibernate

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...