Hi i could use some help here. I'm using Hibernate to integrate with a Payments and Payees table.
The Payee table has alot of columns and i need them all the mapped to the Payee object. Check.
But when i populate the Payments object i only want Payee's moreStuff field ( b/c i will be serializing the Payment object later on and don't want all the bulk )
So i feel like i need the many-to-one mapping. But i need something to specify that i just want the moreStuff String field not the tonsOfStuff field(s).
Does this make sense? Is there a way to do this with Hibernate?
Code:
<hibernate-mapping package="com.something">
<class name="Payment" table="Payments" schema="dbo" catalog="APX2000">
<id name="paymentId" type="int">
<column name="paymentId" />
<generator class="native" />
</id>
<property name="stuff" type="string">
<column name="stuff" />
</property>
<many-to-one name="payee" class="Payee" fetch="select" access="property">
<column name="payeeId" />
</many-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping package="com.something">
<class name="Payee" table="Payees" schema="dbo" catalog="APX2000">
<id name="payeeId" type="int">
<column name="payeeId" />
<generator class="native" />
</id>
<property name="moreStuff" type="string">
<column name="moreStuff" />
</property>
<property name="tonsOfStuff" type="string">
<column name="tonsOfStuff" />
</property>
</class>
</hibernate-mapping>
And here's the database schema:
Code:
CREATE TABLE Payments
(
paymentId int IDENTITY(1,1) NOT NULL PRIMARY KEY,
stuff varchar(20),
payeeId int FOREIGN KEY REFERENCES Payees(payeeId),
)
CREATE TABLE Payees
(
payeeId int IDENTITY(1,1) NOT NULL PRIMARY KEY,
moreStuff varchar(20),
tonsOfStuff varchar(20),
)