orm

Hibernate : Foreign key has the wrong number of column. should be 0

Hi , I am trying to evaluate a mapping in this Hibernate document : section 2.2.3.1. Generating the identifier property http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-identifier In the document , Person and MedicalHistory has @OneToOne mapping (MedicalHistory points to Person) , and the do...

Doctrine 2 Classloader weird behaviour - wrong paths to classes

Hi Guys, I'm having a bit of a problem with Classloader added to Doctrine 2 project. I have simple directory structure like this: config (bootstrap file) html (docroot with templates/images/js etc) php Entities (doctrine 2 entities) Responses (some transport objects) Services (processing api and business logic - like session beans in ...

JPA/Hibernate mapping dynamic columns as a List of objects

I have an existing DB schema which I'm trying to ORM'ise with JPA/Hibernate annotations. The schema is designed to allow for clients to assoicate extra information with each row in a table. Rather than using a key-value pattern the existing solution determines the required number of dynamic columns at install time, and alters the table t...

JPA/EclipseLink - Retrieve Columns Names

Hi, I'm trying to update my knowledge in Java, since I last used in when it was in 1.4.X version... I'm trying to use 1.6.0, in particular the Java Persistence API (2.0). I managed to create an entity class. It's working, since I'm able to store and retrieve data. But I was fooling around and when I decided to fill a JList with the co...

ORM mapper for windows 7 phone

I thinking of using SQLite with win7 phone for development of my app. I looking for an ORM mapper which will work with Windows 7 phone and SQLite. ...

Bulk insert with sqlAlchemy ORM

Is there any way to get sqlalchemy to do a bulk insert rather than inserting each individual object. i.e., doing: INSERT INTO `foo` (`bar`) VALUES (1), (2), (3) rather than: INSERT INTO `foo` (`bar`) VALUES (1) INSERT INTO `foo` (`bar`) VALUES (2) INSERT INTO `foo` (`bar`) VALUES (3) I've just converted some code to use sqlalchemy...

Can the .netTiers framework be used with windows forms

Does nettiers available for windows form? it is very good template for codesmith code generator. asked because of : this http://community.codesmithtools.com/nettiers/f/16/p/11316/43250.aspx#43250 if yes give me link for more information, ...

How to use JPA2's @Cacheable instead of Hibernate's @Cache

Typically , I use Hibernate's @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) to cache an @Entity class , and it works well. In JPA2 , there's another @Cacheable annotation that seems to be the same functionality with Hibernate's @Cache. To make my entity class independent of hibernate's package , I want to give it a try....

Strange hibernate exception when running under Linux

I have a project that compiles and runs completely fine under OS/X, but under Linux an exception is thrown that gives no clue as to what might be the problem. I've been stuck on this for hours trying to narrow it down, any pointers would be helpful! java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) ...

How to change JPA 2.0 SQL/JPQL queries dynamically in production

Hello! I have a problem with the architecture of JPA 2.0/ORM, in our production system (and i believe in a lot of systems) we need the ability to change the SQL queries dynamically because slow queries and bugs in queries that was exposed only in production (heavy load and heavy data), as a result we used in stored procedures and call t...

Simple jpa question

I have to go through some code of a project to implement some missiong functionality. It uses jpa.In some popj classes i have found @Entity @Table(name="TYPE") @NamedQueries( { @NamedQuery(name = "getTypes", query = "SELECT dct FROM Type dct") }) I know that i can used to get all records by using this query.Does this query return ...

Hibernate retrieving list from onetomany

Hi guys, I managed (as you can see in older posts from me) to insert a onetomany relation through hibernate. My two entity classes look like following: Project.java: @Entity public class Project { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @OneToMany(cascade = CascadeType.ALL, mappedBy="project") ...

JPQL LIKE expression on enum

Can JPQL execute LIKE expressions against enums? If I have an entity Foo with an enum field bar I can execute the following in MySQL(bar is stored as a MySQL enum)... SELECT * FROM Foo WHERE `bar` LIKE '%SUFFIX' However, the corresponding query in JPQL... SELECT f FROM Foo f WHERE f.bar LIKE '%SUFFIX' ...complains that... Param...

How to mimic upsert behavior using Hibernate?

Hello all, I'm writing an application that sync's entities from a third party datasource into our own schema, with a transformation/mapping step in between. I'm using Hibernate to represent and persist the entities in our own schema. A problem I'm running into is that I have a unique multi-column key on one of my tables. The behavior...

"where exists" in Hibernate HQL

Hello Overflowers, How can I write a "not exists" query in HQL? I am trying to get an HQL not exists query which returns the same results as this Oracle SQL query: select * from SCHOOL a where not exists (select 1 from STUDENT b where B.SCHOOL_ID=a.id and B.STATUS_ID not in (0,1,2,3,4)) My mapping files are below: <!-- prim...

Storing inherited objects in a database

I'm trying to figure out the best way to map inheritance relationships in an object model into a relational database. For example consider the following class structure. public Class Item { public String Name{get; set;} public int Size {get; set} } public Class Widget:Item { public String Color{get; set;} } public Cla...

Get distinct months from database using HQL

Hi I have a java.util.Date field in an @Entity and would like to get the distinct months from that column. Suppose I only had three rows, with 14/07/2010, 24/11/1975 and 03/11/1975 (European date format - day/month/year), I would like to get the following back from Hibernate to go into a dropdown for filtering the data: 07/2010 11/197...

Problem in saving List<String> through JPA?

I have already seen http://stackoverflow.com/questions/287201/how-to-persist-a-property-of-type-liststringin-jpa and http://stackoverflow.com/questions/796347/map-a-list-of-strings-with-jpa-hibernate-annotations ============================================================================= I am trying to save List<String> throu...

Is there a simple workflow to generate a database schema from classes with hibernate mappings?

Id like to define my objects then use hibernate to generate my ddl from this. But it seems like the only real workflow with hibernate is to generate a datbase schema and then reverse engineer it. Am I wanting to do something that makes no sense? ...

JPA Query MONTH/YEAR functions

How can I write a JPA query using MONTH function just like sql query? @NamedQuery(name="querybymonth", query="select t from table1 t where MONTH(c_Date) = 5") When I use the above pattern for query, I get an error: unexpected token - MONTH. ...