Hello good people i came accross a weird behaviour in my test.I'm using JPA hibernate annotation with spring.
let say i have an Class MyObject and it's property email is marqued
@Column(name="EMAIL", length=100, unique=true)
private String email;
i prepare for what i need to be in the database in the setup of this class MyObjectDAOImp...
Hi there,
suppose I have an entity "Employee", and an entity "Address". An employee has an address associated to him/her. In a relational database sense, the Address table would be considered a weak entity, since an employee address cannot exist if there is no corresponding Employee in the database. Thus, suppose I want to model the fol...
Hello everyone,
I would like to order a query by a function which uses properties of the class. Something like:
@entity
class A
{
private int id;
private String name;
public int StringLength()
{
return name.length();
}
}
And the sentence something like: "select n from A order by name.StringLength()". Is it possible?
Thanks in advan...
I'm trying to add a composite primary key to a class and having a bit of trouble. Here are the classes.
class User {
private long id;
...
}
class Token {
private User user;
private String series;
...
}
I'm using the orm.xml to map the classes because they're actually part of a higher level API that I don't want to...
hello good people! thanks to you guys my knowlegde on hibernate has been improve dratiscally.
now i hit a block here about current_timestamp.
here is my codes
@Column(name="DATE_CREATED", insertable=false, updatable=false, columnDefinition="timestamp default current_timestamp")
@org.hibernate.annotations.Generated(value=GenerationTime....
I have project use EJB 3.0 and implement Toplink framework for model layer.
When using EJBQL to process data, I see it seems have some limitation:
It cannot process datatime such as find a part of date such as day, month or year
It cannot find datetime among from...to
It cannot comparison datetime field
It cannot map a class not entit...
Hi there,
Is it possible to make a foreign key unique within a table?
Suppose I have entities A and B.
A:
@Entity
class A extends Serializable {
@Id
private long id;
@OneToOne
private B b;
}
B:
@Entity
class B extends Serializable {
@Id
private long id;
}
I want to make it so that an A can have a B, except there can be no other ...
I'm new to EJB and trying to get my head around translating SQL concepts to EJB entity beans.
Suppose I have two tables: PEOPLE (id, name), CONTACT(pid, phone_number). If I want to get a list of all people whether or not they have phone #s, in my EJB session bean I simply issue a SQL query via JDBC such as:
SELECT PEOPLE.name, CONT...
Is it possible for a Primary Key of an nested Entity to be used as the Primary Key of the Nest Entity?
For Example:
If I had a Entity 'Staff' who has a primary key 'EID' and has the nested Entity 'Job'. The Entity 'Job' has a primary key 'JID', and a Discriminator type 'DTYPE' so that sub classes of Job may be stored in the DTYPE alo...
Hello good people.
I 'm trying to build a user and a contact management project.
i have a lot of classes so will limit it to what are in concern here. i have a userAccount, userProfile, and group
here is the UserAccount Mapping
@Id @GeneratedValue
@Column(name="USER_ACCOUNT_ID")
private Long ID;
......
@Column(name="EMAIL", length=10...
Hi,
I have one jar library A (or project in eclipse), which has it's own persistence unit (META-INF/persistence.xml) and some entity classes, and another project (B) using this one. In project B there is also persistence unit and entity classes.
In project B I need to use both entity classes from project A and B. But if I set "A" as pe...
I'm playing around a bit with JPA(Eclipselink to be specific). The below entity have a
timestamp that's supposed to reflect whenever that entity was last updated.
What are the strategies for making JPA update that timestamp automatically every time
this entity is changed ?
How would I go about if I also want a 'creation' timestamp, on...
I ran some DDL script to setup a complete country table in my database. The country table's primary key column contains the corresponding ISO code for every country.
In my JPA project I have a User entity having an embedded Address entity and this Address entity has a reference to a Country. The relationship between User and Address se...
hello i'm not sure whether the title depicts the my situation very well.I'm developing a user and contact managment system with hibernate. i have an UserAccount pojo, contact pojo and phone object.i limited it to 3 since since those are in concern.UserAccount has a bidirectional with contact, and both have unidirectional with phone pojo....
I'm using JPA for a project and in most cases, want to get entities, but there are a few cases (reporting being one of them, but there are others) where I do not want or need to get entities, but rather want a selection of values. Does JPA support this? If so, does it make sense to use it or does it make sense to use straight JDBC in the...
We are implementing a web page to maintain an organisational structure. The structure is stored in SQL Server 2008 and uses the new HierarchyID data type. Because we have had problems getting JPA and Hibernate to play with this new data type we have decided to use views and stored procedures to abstract away this data type. So we want to...
I am using JPA in addition to spring(3.0.0.M4). While deleting multiple records using query.executeUpdate() i am getting the following exception.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: query must begin with SELE...
I've got a requirement where a user enters a few terms into a search box and clicks "go". Does anyone have any good resources on how to implement a dynamic search that spans a few database tables? I am using jsp,servelt,jpa as front end and mysql at back end of my project.
Thanks, Satya
...
what is similarity and difference between jpa and hibernate.
...
I am trying to implement JPA with inheritance for an existing database.
The current db model is the following:
Instrument
* InstrumentID
* Description
* InstrumentTypeID
InstrumentType
* InstrumentTypeID
* StorageClass
Option
* InstrumentID
* (Option specific fields)
Stock
* InstrumentID
* (Stock specific fields)
There is...