eclipselink + JPA + Postgresql - is possible embedded ? [message #659747] |
Tue, 15 March 2011 13:21 |
Adam Messages: 6 Registered: March 2011 |
Junior Member |
|
|
Hello everyone,
I'm begginer in Java and also in JPA.. Unfortunately i have to work with postgresql + JPA + eclipselink, because is my school project. Database is final and i can't do any changes even if i wanted to. In structure of DB is this.
--
-- Name: address; Type: TYPE; Schema: artio; Owner: facman
--
CREATE TYPE address AS (
street character varying,
city character varying,
state character varying,
country character varying,
zip character varying,
note character varying
);
ALTER TYPE artio.address OWNER TO facman;
here is screenshot of this custom type in my table http://img822.imageshack.us/i/18591958.png
1. is even possible to use @embedded and @AttributeOverrides for postgresql ?
I was trying by myself some code : but no success. Because if i want select directly street, i must use in sql something like this:
(address)."street" ... but if i want to save something it must be address."street" without "( )" and this is the issue.
@Entity
@Table(name = "\"Property\"", catalog = "", schema = "public", uniqueConstraints = {@UniqueConstraint(columnNames = {"code"})})
public class Property implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "\"propertyID\"", nullable = false)
private Long propertyID;
@Column(name = "code", length = 20)
private String code;
@Basic(optional = false)
@Column(name = "\"name\"", nullable = false, length = 200)
private String name;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "street", column =
@Column(name = "********"))
})
private Address address;
I don't know what i should put instead ********* because if i put there "address" then i get object: Address.getStreet() but in this object is all address means (Street,city,state,zip...)
if i put street instead of ******* than i have sql error that column street does not exist, which is right. It doesn't . Only way i can get it is (address).street but if i put this instead of ****** than i get the same error as previous. System somehow change (address).street only into street. I need help how deal with it. I need to be able to selected/insert/update separate part of address as street,city,etc.
public class Address implements Serializable {
protected String street;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}
I spend 14 hours to find out and im exhausted.
PLEASE HELP ME
Best Regards Adam
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04029 seconds