orm

Dealing with schema upgrades while using Hibernate

I'm using Hibernate as the ORM for my application. I would like to know if there is a good solution to dealing with schema upgrades in my application when these upgrades are done by someone else. For example, I have a set of hbm.xml files and corresponding java classes generated using Hibernate tools. Now in production, everything works ...

Is it worth a try LINQ to SQL as a beginner to an ORM?

Thus far used sql server stored procedures for all my web applications... Now thought of moving to an ORM... I would like to ask SO users about LINQ to SQL Is Linq to sql worth a try as a beginner to an ORM? or should i look for some others... Any suggestion... EDIT: I have a sql server 2005 database with all tables.... How to use t...

How to make an entity out of a join table without primary key

I'm trying to generate JPA entities out of an existing database having an "interesting" design. Database has a table called UserSet, which can have links to several other UserSets. There is a one to many relation between UserSets and LinkedUserSets. LinkedUserSets also has one to one relation to UserSets. I tried to generate a JPA Enti...

how to count all distinct records in many-to-many relations in django ORM?

hi, i have two models: class Project(models.Model): categories = models.ManyToManyField(Category) class Category(models.Model): name = models.CharField() now, i make some queryset: query = Project.objects.filter(id__in=[1,2,3,4]) and i like to get list of all distinct categories in this queryset with count of projects with refer...

Does @JoinTable has a property of "table" or not?

The following is copied from hibernate's document. (http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e2770) @CollectionOfElements @JoinTable( table=@Table(name="BoyFavoriteNumbers"), joinColumns = @JoinColumn(name="BoyId") ) @Column(name="favoriteNumber", nullable=fals...

CF9 HQL Statement for many-to-many and Multiple Criteria

I have the following setup: Listing.cfc component persistent="true" { property name="ListingId" column="ListingId" type="numeric" ormtype="int" fieldtype="id" generator="identity"; ... property name="Features" type="array" hint="Array of features" singularname="Feature" fieldtype="many-to-many" cfc="Feature" linktable=...

Example for creating a configuration

hi, i am facing some difficulties in creating a session. Can anyone provide me an example or link where a configuration is created by using an external file by giving url,like Configuration config = new Configuration.configure(url); the config file is in another hibernate project. is there anything that i should add to classpath o...

Is there a way to get only the changed columns from an object using Hibernate?

In a persistent object, If i change only one field, Is it possible to find out the changed field only through Hibernate? I know I can get the entire old row and new row and compare. ...

JPA Problems mapping relationships

Hello. I have a problem when I try to persist my model. An exception is thrown when creating the EntityManagerFactory: Blockquote javax.persistence.PersistenceException: [PersistenceUnit: ASD] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) ...

Hibernate generate POJOs with Equals

We are using hibernate in a new project where we use the hibernate.reveng.xml to create our *.hbm.xml files and POJOs after that. We want to have equals methods in each of our POJOs. I found that you can use <meta attribute="use-in-equals">true</meta> in your hbm files to mark which properties to use in the equals. But this would mean e...

one to many mapping within the same table in Hibernate..

I have a table containing primary key and foreign key that references same table. How can I implement this mapping in hibernate... structure of tables is as follows.. Dept ( deptno pk, dname, location ) employee ( empid pk, ename, Manager Id Foregin key references Employee(empid), deptno Foregin key referen...

where is the best palce to count the lazy load property using JPA

Let's say we have a "Question" and "Answer" entity, @Entity public class Question extends IdEntity { @Lob private String content; @Transient private int answerTotal; @OneToMany(fetch = FetchType.LAZY) private List<Answer> answers = new ArrayList<Answer>(); ...... I need to tell how many answers for the...

ColdFusion 9 ORM/Hibernate and Remoting

Why does my cfc method (when returning JSON format or called via remoting) return all related objects regardless of the lazy setting on the property? ...

Making serach on database and Listing results with Hibernate in Java

I am developing swing based application with hibernate in java . And ı want to make search on database , and listing result... Before ı used to JDBC and ResultSetTableModel , and my before code is here : try{ Class.forName("*****************").newInstance(); Connection baglan=(Connection) DriverManager.getConnection("*******...

hibernate show real sql

Hi all, if I set <property name="show_sql">true</property> in my hibernate.cfg.xml configuration file in the console I can see the sql. But it's not REAL sql... Can I see the SQL code that will be passed directly to database? Example: I see select this_.code from true.employee this_ where this_.code=? Can I see select employe...

Hibernate @Index on @Enumerated field doesn't work

I am using Hibernate to talk to my DB. I have one field that is an enumeration and it is going to be used in a slow query. So I'd like to index it. I've put the following annotations on the field: @Column(name="RIGHT_TYPE", unique=false, nullable=false, length=10) @Enumerated(EnumType.STRING) @Index(name = "ABC_INDEX") protected RightTy...

Lightweight Object->Database in python

I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that: Creates a database table from a simple type description (int, float, datetime etc) Takes a dictionary object and inserts it into the database (including handling datetime objects!) If possible: Can handle basic references, s...

How to generate comments in hbm2java created POJO?

My current setup using hibernate uses the hibernate.reveng.xml file to generate the various hbm.xml files. Which are then turned into POJOs using hbm2java. We spent some time while designing our schema, to place some pretty decent descriptions on the Tables and there columns. I am able to pull these descriptions into the hbm.xml files wh...

Does beginTransaction in Hibernate allocate a new DB connection?

Hi folks - Just wondering if beginning a new transaction in Hibernate actually allocates a connection to the DB? I'm concerned b/c our server begins a new transaction for each request received, even if that request doesn't interact with the DB. We're seeing DB connections as a major bottleneck, so I'm wondering if I should take the t...

New to MVVM - Best practices for seperating Data processing thread and UI Thread?

Good day. I have started messing around with the MVVP pattern, and I am having some problems with UI responsiveness versus data processing. I have a program that tracks packages. Shipment and package entities are persisted in SQL database, and are displayed in a WPF view. Upon initial retrieval of the records, there is a noticeable p...