hibernate

archiving strategies and limitations of data in a table

Environment: Jboss, Mysql, JPA, Hibernate Our web application will be catering to a large amount of users (~ 1,000,000) and there are a lots of child table where user specific data are stored (e.g. personal, health, forum contributions ...). What would be the best practice to archive user & user specific information. [a] Would it be...

Is it possible for a Grails Domain to have no 'id'?

Is it possible to create a table that has no 'id'? For example, this is my domain: class SnbrActVector { int nid String term double weight static mapping = { version false id generator: 'identity' } static constraints = { } } When I run this SQL statement, it fails: insert into snbr_act_...

Hibernate 1:M relationship ,row order, constant values table and concurrency

table A and B need to have 1:M relationship a and b are added during application runtime, so A created, then say 4 B's created. Each B instance has to come in order, so that I could later extract them in the same order as I added them. The app will be a web-app running on Tomcat, so 10 instances may work simultaneously. So my question...

In a bidirectional JPA OneToMany/ManyToOne association, what is meant by "the inverse side of the association"?

In these examples on TopLink JPA Annotation Reference: Example 1-59 @OneToMany - Customer Class With Generics @Entity public class Customer implements Serializable { ... @OneToMany(cascade=ALL, mappedBy="customer") public Set<Order> getOrders() { return orders; } ... } Example 1-60 @ManyToOne - Order Cla...

How to store some of the entity's values in another table using hibernate?

Hi guys, is there a simple way to persist some of the fields in another class and table using hibernate. For example, I have a Person class with name, surname, email, address1, address2, city, country fields. I want my classes to be: public class Person { private String name; private String surname; private String email; pr...

Hibernate recursive deletion

Hi,I have the following mapping: Person class mapping: <hibernate-mapping ...> <class="my.Person" table="PERSON" where="deleted is null"> ... <sql-delete> update PERSON set deleted = true where id=? </sql-delete> </class> </hibernate-mapping> Geek class mapping: <hibernate-mapping ...> <joined-subclass name="my.G...

Hibernate/JPA DB Schema Generation Best Practices

I just wanted to hear the opinion of Hibernate experts about DB schema generation best practices for Hibernate/JPA based projects. Especially: What strategy to use when the project has just started? Is it recommended to let Hibernate automatically generate the schema in this phase or is it better to create the database tables manually ...

Interfaces with hibernate annotations

Hello i am wondering how i would be able to annotate an interface @Entity @Table(name = "FOLDER_TABLE") public class Folder implements Serializable, Hierarchy { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_id", updatable = false, nullable = false) private int fId; @Column(name = "folder_name") private St...

Hibernate 3.5-Final in JBoss 5.1.0.GA

Hibernate 3.5-Final is finally here and it offers the much anticipated JPA2 support, amongst other features. I am working on a project(EJB3 based) using JBoss 5.1.0.GA and Hibernate 3.3, but I wanted to take advantage of the JPA2 and tried to upgrade to Hibernate 3.5. What I did was fairly simple and standard - I just put all the hibern...

Hibernate sending superfluous queries to the database.

I have an odd problem where Hibernate is running more queries than I've asked for, and can't see the need for. Here is my controller: @Autowired UserService users; @RequestMapping("/test") @ResponseBody public String test() { User user = users.findUser(1L); return "Found user: "+user.getEmail(); } Here is the UserService: @...

How do I get spring to inject my EntityManager?

I'm following the guide here, but when the DAO executes, the EntityManager is null. I've tried a number of fixes I found in the comments on the guide, on various forums, and here (including this), to no avail. No matter what I seem to do the EntityManager remains null. Here are the relevant files, with packages etc changed to protect ...

Get the ID of a Child in a cascade="all" relationship, while adding it to a collection, in Hibernate

Hi, i have two Entities, "Parent" and "Child", that are linked through a bidirectional one-to-many relationship with the cascade attribute set to "all". When adding a Child object to the Parent children collection using the code below, i can't get the ID of the persisted child until i commit the transaction: Parent p = (Parent) session....

Hibernate GenericDAO for parent/child relationships and DAO/DTO patterns

Hi, I'm looking for a Generic DAO implementation in Hibernate that includes parent/child relationship management (adding, removing, getting children, setting parents, etc). Actually the most used generic DAO on the web is the one I found on jboss.org. And also, i was looking for some DAO/DTO sample implementations and design pattern...

Hibernate Criteria: Return different entity type than rooted entity?

I have entities similar to: ProductLine: id, name ProductLineContents: content_id, product_line_id Content: id, text, updated_time What I'd like to do is: for each product line, get the latest content (so if theres two content entries associated to one product line, the latest updated_time is rturned, and if one content item is associ...

what's the best practice to config Hibernate-Spring for multiple database relationship?

We have a main mysql database which all of the applications within our organization need the data within this database. How can I config my java web application to use this database with it's specific database when I use Spring and Hibernate within my application? How can I config JPA annotations for example between CONTRACT table within...

Hibernate reverse engineering procedure generated @Temporal(TemporalType.TIMESTAMP) for DateTime

Fields in a DB were of type DATETIME (mysql). Why was it generated as a timestamp and will it be regenerated during object persistence? That is not a desired scenario in my case, seeing that as not a timestamp field means that it should only be set via setter, no generation needed, I dont really understand why it did not generate it...

is it hibernate cache problem?

Hi all, I am using jasper report to generate a report while calculating total from database.I am sending this as a parameter to jasper.But sometimes it gives wrong values for a total. I am using Hibernate as a OR-Mapping tool. In my application i am generating reports from database.In some reports it gives wrong values whereas the cod...

JPA - Removing entities

I have a Story entity with the following associations: Story <1-*> Chapter Story <1-*> Comment Story <*-1> User What is the correct way of removing this entity and handling the all the entities that is referring to? Is there some shorthand way of specifying that associated entities must be handled automatically or is the @PreRemove a...

Working with hibernate/DAO problems

Hello everyone here is my DAO class : public class UsersDAO extends HibernateDaoSupport { private static final Log log = LogFactory.getLog(UsersDAO.class); protected void initDao() { //do nothing } public void save(User transientInstance) { log.debug("saving Users instance"); try { ...

Hibernate cascading

All what Hibernate reverse engineering generates is something like this @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "column_id") public Itinerary getColumnId() { return this.columnId; } I want this scenario: when session flushes, first all constructed childs were saved, then the parent object, accord...