I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool to create a mapping for that table, it generates two classes, one for named after the table itself, and one with an "Id" suffix. It seems most of the useful methods ended up ...
I have the following entity class (in Groovy):
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
public class ServerNode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
String firstName
String lastName
}
and m...
I've been stuck with this query for some time now. The SQL returns the result that I want, but I cannot work out how to express the query in HQL.
Here's the SQL:
select thread.ThreadId,
thread.Title,
thread.CreatedOn,
thread.ViewCount,
thread.CreatedBy,
thread.ForumId
from Threads thread
where
(...
I have this Java code (JPA):
String queryString = "SELECT b , sum(v.votedPoints) as votedPoint " +
" FROM Bookmarks b " +
" LEFT OUTER JOIN Votes v " +
" on (v.organizationId = b.organizationId) " +
"WHERE b.userId = 101 " +
...
Are there any tools that auto-generate the hibernate POJOs by gathering information from the database?
I made a perl script to do this after the schema got changed for the third or fourth time in a project i'm working with and just wondered if there is any established tool that will do this for me as my script is rather crude and needs ...
Hi,
Until recently we used Oracle sequences to generate the IDs of a table. This is now changed, a new ID is now calculated by an Oracle function. Which means that my application needs a change to adept to the new situation. The application is a Spring/Hibernate webApp, which access the Oracle database. This was configured in an hbm.xml...
I'm using hibernate 3 and want to stop it from dumping all the startup messages to the console. I tried commenting out the stdout lines in log4j.properties but no luck. I've pasted my log file below. Also I'm using eclipse with the standard project structure and have a copy of log4j.properties in both the root of the project folder and t...
Can somebody please give me an example of a unidirectional @OneToOne primary-key mapping in Hibernate ? I've tried numerous combinations, and so far the best thing I've gotten is this :
@Entity
@Table(name = "paper_cheque_stop_metadata")
@org.hibernate.annotations.Entity(mutable = false)
public class PaperChequeStopMetadata implements S...
I have following POJOs:
class Month {
long id;
String description;
List<Day> days; // always contains 29, 30 or 31 elements
}
class Day {
byte nr; // possible values are 1-31
String info;
}
Is there a way to store these objects into following DB structure using JPA+Hibernate:
Table MONTHS:
id;description;
Table...
Hello,
I 'd like to use Criteria for my SQL query.
I have 3 tables "home", "person" and a third table "liveIn" for correspondance between home and person.
My sql query is
"select home.id
from home, person, liveIn
where home.country = 'Japan'
and person.id = '15'
and liveIn.Homeid = home.id
and liveIn.PersonId = person.id"
A little hel...
I have a table with a timestamp field of type datetime. I need to aggregate the data between a defined start and end time into x groups representing time intervals of equal length, where x is supplied as function parameter.
What would be the best way to do this with Hibernate?
EDIT: some explanations
mysql Table:
data_ts: datetime pk...
I've created a UserObject and RoleObject to represent users in my application. I'm trying to use hibernate for CRUD instead of raw JDBC. I've successfully retrieved the information from the data base, but I can not create new users. I get the following error.
org.springframework.web.util.NestedServletException: Request processing fa...
I have an entity that maps to an external oracle table which is one of the primary data sources of my application. This entity is modelled using hibernate.
The oracle table now has a complex function defined the calculates some special values. I need to call this funtion somehow - almost as another accessor on the entity.
What would yo...
Can anyone point me out, how can I parse/evaluate HQL and get map where key is table alias and value - full qualified class name.
E.g. for HQL
SELECT a.id from Foo a INNER JOIN a.test b
I wish to have pairs:
a, package1.Foo
b. package2.TestClassName
It's relatively easy to do for result set
HQLQueryPlan hqlPlan = ((SessionFac...
I create new project in Netbeans, but when i look the library it still using JDK 1.6 (default) i want to change into JDK 6 Update 10 but how? i already instal JDK 6 Update 10 but when i import org.hibernate the neatbeans didn't know which library that org.hibernate.
someone can help me? THX
...
I'm considering using Annotations to define my Hibernate mappings but have run into a problem: I want to use a base entity class to define common fields (including the ID field) but I want different tables to have different ID generation strategies:
@MappedSuperclass
public abstract class Base implements Serializable {
@Id
@Col...
Hi
I'm trying to configure Hibernate classes not through XML/Annotation, but using their programmatic API:
Mappings mappings = configuration.createMappings();
mappings.addClass(...);
An example of column addition:
public void addColumn(String colName, String accessorName, NullableType type)
{
if(this._table == null...
I've been facing this issue where, the hibernate objects on serialization produces unexpect xmls containing all the instrumented code from Hibernate.
We did some cleaning of the object before serializing the object.
But, is there a standard option available to serialize the object directly?
...
Hello there.
Does hibernate HQL queries support using select min, max, count and other sql functions?
like
select min(p.age)
from person p
Thanks
...
Is it possible for a JPA entity class to contain two embedded (@Embedded) fields? An example would be:
@Entity
public class Person {
@Embedded
public Address home;
@Embedded
public Address work;
}
public class Address {
public String street;
...
}
In this case a Person can contain two Address instances - home...