hibernate

Hibernate Query to fetch records on date ignoring timestamp

I have a timestamp column tradedate in one of the DB(Oracle) tables. I am using hibernate as the persistence layer to fetch and store Data to DB. I have a requirement in which I need to query the DB on date. i.e From UI the user passes a date and I need to get the filtered data based on this date. If the tradedate column only has the d...

hibernate question

if i use table name instead of class name in HQL query like this: select classname.field name as obj from table name and i have specified mapping in hbm file. but it show exception: table name is not mapped and second thing is i have use on keyword in query then it show exception: unexpected token: on ...

Retrieving Blob from MySQL database in Hibernate / JSF application

I am having some trouble properly retrieving blob data from my database using java in my JSF 2.0 application. The first problem I am having is on my getter method for the Blob named "file" I get an error saying that "Basic attributes can only be of the following types..." basically saying that I can not return a Blob object. My code look...

how can we achieve relationship in hibernate

i have two tables... i want to get data from second table using primary key of first table...that primary key was act as foreign key in second table...how can retrieve from that table in hibernate... ...

hibernate mapping files

I have a table for class UserStatus ( userId varchar, statusId bigint). Set statusId to autoincrement and specify userId as primary key for some optimisation because most request goes with userId. Using Eclipse. After reverse engineering receive such file: <class name="xxx.UserStatus" table="user_statuses" catalog="xxx"> <id nam...

Temporal libraries for Java

I'm looking for temporal libraries for Java, i.e. libraries which allow to store multiple historical version of the same concept. I'm looking for a library which has an API to do something like: Instant i1 = Instant.valueOf("2010-01-01"); Instant i2 = Instant.valueOf("2010-01-02"); Attribute<String> a = .... a.setValue(i1, "String as ...

Using @GeneratedValue(strategy=GenerationType.TABLE), the sequence_next_hi_value is an int(11) but my table have a id column bigint(20)

Hello, I am using @Id with @GeneratedValue(strategy=GenerationType.TABLE), just checked that hibernate have created a table hibernate_sequences, but the column type for the sequence_next_hi_value is an int(11). I have some entities (I mean tables) that have an id field of type bigint(20), will that works ? and when my table reach the nu...

Need to put @Index even when I marked with @Column(unique=true) ?

Hello, Need to put @Index even when I marked with @Column(unique=true) ? I have a property that will be used frequently to retrieve the entity and wanted to make it an index column on the database. So this property is already marked with @Column(unique=true), do I need to put @Index? thanks ...

Do you think it is necessary to mark id fields with insertable = false and updatable = false ?

Do you think it is necessary to mark id fields with insertable = false and updatable = false ? I haven't seem much people doing this before, but today I checked one code that used these properties setted to false for an id field. Regards ...

DB machine CPU cycles Vs mid-tier machine CPU cycles

I have a SELECT query with lot of IF conditions, which I can do either in the query itself (takes DB machine's CPU) or I can put it in my java code (takes server machine's CPU). Is there any preferred approach here (to put conditions in DB Vs in mid-tier)? UPDATE: My query is a join on more than 2 tables, and I am using left join to co...

how resolve hibernate Envers Configuration Error?

Hi here i am using hibernate hbm file to all model class. Now I need to audit the details of that class. I tried to use hibernate envers. I had created a new class with @Audited annotation . Then i cofigured my hibernate.cfg.xml with my new class and Envers Configuration like <listener class="org.hibernate.envers.event.AuditEventListener...

Call AES_ENCRYPT function in hibernate

How can I execute this query in hibernate? SELECT AES_ENCRYPT('admin','password') ...

Constraint violation in Hibernate unidirectional OneToMany mapping with JoinTable and OrderColumn when removing elements

Hi, I have a problem when removing elements from a list mapped as described above. Here is the mapping: @Entity @Table( name = "foo") class Foo { private List bars; @OneToMany @OrderColumn( name = "order_index" ) @JoinTable( name = "foo_bar_map", joinColumns = @JoinColumn( name = "foo_id" ), inverseJoinColumns = @Jo...

grails unidirectional one-to-many

this has been bugging me, lets say i have two model, category and product class Category { static hasMany = [products : Product] String name } .. class Product { String name } now, i want to delete product, which happens to exist in many category. i came up with these lines in my product beforeDelete methods def beforeDelete =...

how to associate single entity to multiple entities(pojo classes)

hello, does anyone here knows the correct way of associating a single entity(a pojo class) to multiple classes.. im currently working on a situation where mainClass has a one-to-many relationship to subClass and subClass has one-to-many relationship to unitsClass too. the relationship of these classes looks like this: mainClass - oneTo...

JBoss Classloader Repository

Hi all, Running JBoss 4.2.3.GA and trying to deploy a WAR that is using Spring/Hibernate/JPA. I'm getting ClassCastExceptions (quite a lot of different ones) so I'm trying to setup a Classloader Repository for my WAR. This is my catalog.war/WEB-INF/jboss-web.xml file <jboss-web> <loader-repository> com.moo.catalog:loader=...

What is reason to declare not-null feild in hibernate Proeprty tag?

Hi, What will happen if i declare DB null feild as not null in Mapping file. Or if not specified anything in the Proeprty coulmn but it is an not-null feild in DB?I am confued. please help. ...

Implementing sequence in Java using Hibernate

Hi, I am using Java and Hibernate as ORM tool. Is there any way i can implement sequence in Java using Hibernate? Currently I am using Oracle sequences to achieve this, but that is a very costly way as interaction with database increases. Please help. ...

JPA/Hibernate: What's better for composite primary keys, @IdClass or @EmbeddedId implementations and why?

Hello, what's better for JPA/Hibernate composite primary keys, @IdClass or @EmbeddedId implementations and why? This is an intentionally naive question. I decided to use @EmbeddedId (for whatever reason) and I feel like I made the wrong choice. Dereferencing the embeddedId that contains the column properties is redundant and quite erro...

Does JPA support a kind of "Any" mapping for embeddable objects?

Hi, I'm extending the data model of an Java application to include some kind of a setting facility. Settings in this application would basically be Strings or Numbers, no entities or other model objects. My Question is what's the best way to map this requirement to JPA (Hibernate)? I first thought about implementing a Setting class wi...