Help! one to many relationship table and display output as exists
I have two tables:
Table1: LOCATION with field locn_id
Table2: TRACKING with field from_locn and to_locn
Example
locn_id from_locn to_locn
26001A 26001A 26002A
26002A 26001A 26001B
26001B 26001A 26001C
26001C
I am linking locn_id to from_locn.
I want to display output as:
If locn_id exists in from_locn (I dont care how many records), display Y. If locn_id does not exist then display N.
So in above case, output should be
26001A Y
26002A N
26001B N
26001C N
Here is my try:
create table LOCATION(locn_id VARCHAR2(10));
create table TRACKING(locn_id VARCHAR2(10), from_locn VARCHAR2(10), to_locn VARCHAR2(10));
insert into LOCATION values('26001A');
insert into LOCATION values('26002A');
insert into LOCATION values('26001B');
insert into LOCATION values('26001C');
insert into TRACKING values('26001A', '26001A', '26002A');
insert into TRACKING values('26002A', '26001A', '26001B');
insert into TRACKING values('26001B', '26001A', '26001C');
insert into TRACKING values('26001C', '', '' );
select l.locn_id,
(select decode(count(*), 0, 'N', 'Y') from tracking t where l.locn_id = t.from_locn ) exists_flag
from location l
LOCN_ID E
26001A Y
26002A N
26001B N
26001C N
4 rows selected.Edited by: Thomas Morgan on May 31, 2013 3:43 PM
Similar Messages
-
ONE-to-MANY relationship between tables and forms in APEX
I recently started using APEX and I have run into an issue.
I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
A1:
A1_ID
Item
A2:
A2_ID
SubItem
A1_ID
I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
On F2, I have the following fields that are setup to capture data:
A2.A1_ID
**A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
A2.SubItem (user would enter SubItem)
Note: A2.A2_ID is populated using a SEQ
Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
If this will work, how do I go about implementing this solution?
Can someone help me?I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
chris. -
Need help mapping one-to-many relationship
[Sorry, inadvertently cross-posted]
Hello,
I have a one-to-many mapping question that's probably a no-brainer for the
experts of the group out there. My problem is that I can't get a collection
of Items for a given Theme to be populated and I don't know if it's a
problem in my system.jdo or in my classes (or both). For example, for Theme
10,
I want a collection of two Items, item_ids 1 and 2.
I have db tables named ITEM and THEME with the following layouts:
ITEM
|==========================================================|
| item_id(pk) | item_name | item_number | theme_id(fk) |
|==========================================================|
| 1 | This is Item1 | 1234 | 10 |
| 2 | This is Item2 | 2954 | 10 |
| 3 | This is Item3 | 2094 | 17 |
| 4 | This is Item4 | 946 | 11 |
| ... |
|==========================================================|
THEME
|=======================================|
| theme_id(pk) | theme_description |
|=======================================|
| 4 | Space |
| 10 | Town |
| 11 | Train |
| 17 | Pirate |
| ... |
|=======================================|
I have two PersistenceCapable classes that map to the above tables:
package com.lego.data;
public class Item
public int item_id;
private String item_number;
private String item_name;
private int theme_id;
public Theme theme;
public String toString()
return
item_number+":"+item_name+":"+theme.getCode()+":"+theme.getDescription();
package com.lego.data;
import java.util.*;
public class Theme
public int theme_id;
public String theme_description;
public Collection items;
public String toString()
return theme_id+":"+theme_description;
and here is my system.jdo file:
<?xml version = "1.0" encoding = "US-ASCII"?>
<jdo>
<package name="com.lego.data">
<class name="Item" identity-type="application"
objectid-class="com.lego.data.IntOId">
<extension vendor-name="kodo" key="table" value="item"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="class-column" value="none"/>
<field name="item_id" primary-key="true">
<extension vendor-name="kodo" key="data-column" value="item_id"/>
</field>
<field name="item_number">
<extension vendor-name="kodo" key="data-column" value="item_number"/>
</field>
<field name="item_name">
<extension vendor-name="kodo" key="data-column" value="item_name"/>
</field>
<field name="theme_id">
<extension vendor-name="kodo" key="data-column" value="theme_id"/>
</field>
<field name="theme">
<extension vendor-name="kodo" key="theme_id-data-column"
value="theme_id"/>
</field>
</class>
<class name="Theme" identity-type="application"
objectid-class="com.lego.data.ThemeKey">
<extension vendor-name="kodo" key="table" value="theme"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="class-column" value="none"/>
<field name="theme_id" primary-key="true">
<extension vendor-name="kodo" key="data-column" value="theme_id"/>
</field>
<field name="theme_description">
<extension vendor-name="kodo" key="data-column"
value="theme_description"/>
</field>
<field name="items">
<collection element-type="Item"/>
<extension vendor-name="kodo" key="inverse" value="theme"/>
</field>
</class>
</package>
</jdo>
Thanks in advance for the help.
-TimAbe White wrote:
The first thing to check is that you are always setting the "theme" field in
your Items. If you add an Item i to the "themes" collection of a Theme t, but
forget to also set i's "theme" field to t, then the change will never get
written to the database.
Next, make sure that whenever you set the "theme" field of an Item, you also
set
its "theme_id" field. You map both of these fields to the same column, so you
better be sure they stay in synch.
On a related note, you might try making the "theme_id" field non-persistent if
things still aren't working for you. Mapping two fields to the same column
might be causing trouble. It would be safer to make theme_id non-persistent
anyway, and to always grab the id from the Theme stored in your "theme"
field.
Better OO programming and all that, though I can see that you might have
performance issues in mind when doing it your way.
Anyway, if you find that it works when you make theme_id nonpersistent, let us
know and we'll see why the double-mapping of the column is causing problems,
and hopefully find a fix.Abe,
Thanks for the response but I'm still confused. I failed to mention that
the Item and Theme tables are in an existing schema, so as you saw in my
system.jdo, I am specifying application identity.
Since this is an existing schema, the Item table has theme_id as the
foreign key to the Theme table. So are saying that it is a problem to map
the both theme_id as a data column and a Theme object in the Item at the
same time?
I guess what I don't understand is exactly what my system.jdo should look
like to map a one-to-many relationship. In my case, from Theme (1) to Item
(many). (See my system.jdo in previous post).
Thanks
-Tim -
One-to-many relationship: problem with several tables on the one side...
Hello
I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
Anybody knows a solution? I would be obliged.
Regards
HavocadoHi;
A simple way may be create a view on referenced tables:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> drop table resources;
Table dropped
SQL> create table resources(id number, name varchar2(12));
Table created
SQL> insert into resources values(1,'Doc....');
1 row inserted
SQL> insert into resources values(2,'Img....');
1 row inserted
SQL> drop table documents;
Table dropped
SQL> create table documents(id number, resource_id number,type varchar2(12));
Table created
SQL> insert into documents values(1,1,'txt');
1 row inserted
SQL> drop table images;
Table dropped
SQL> create table images(id number, resource_id number,path varchar2(24));
Table created
SQL> insert into images values(1,2,'/data01/images/img01.jpg');
1 row inserted
SQL> create or replace view vw_resource_ref as
2 select id, resource_id, type, null as path from documents
3 union
4 select id, resource_id, null as type, path from images;
View created
SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
ID NAME ID RESOURCE_ID TYPE PATH
1 Doc.... 1 1 txt
2 Img.... 1 2 /data01/images/img01.jpg
SQL> Regards.... -
How to implement one to many relationship between two Document Line Table
Hi,
I want to implement the following relationship into user defined tables:
Example Situation:
There are tables A, B and C.
For one record of Table A, there could be multiple records in table B.
For one record of Table B, there could be multiple records in table C.
i.e. A(1) -> B(n) [One to many relationship]
B(1) -> C(n) [One to many relationship]
finally: A(1) -> B(n) -> C(n)
How can I achieve this? If I make Table A as Document and table B & C as Document Line and then make them UDO, will it work? Kindly suggest me a solution.
Regards,
Sudeshna.Hi,
I think that the database representation is exactly what you ask for. 3 tables, A, B, C. A should have a UDF that is linked to B table, and B should have a UDF that is linked to C table.
You should manage the database transactions, and the UI to support all this stuff.
Regards,
IBai Peñ -
How to join fields from different internal tables and display into one int
hai i have one doubt...
how to join fields from different internal tables and display into one internal table..
if anybody know the ans for this qus tell me......hii
you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
SELECT bwkey " Valuation Area
bukrs " Company Code
FROM t001k
INTO TABLE i_t001k
WHERE bukrs IN s_bukrs.
IF sy-subrc EQ 0.
SELECT bwkey " Valuation Area
werks " Plant
FROM t001w
INTO TABLE i_t001w
FOR ALL ENTRIES IN i_t001k
WHERE bwkey = i_t001k-bwkey
AND werks IN s_werks.
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
wa_output-bukrs = wa_t001k-bukrs.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
regards
twinkal -
JPA one to many relationship and serialization
Hi,
I modeled a one to may relationship like this:
Parent Class WFData:
@OneToMany(mappedBy = "wfData", targetEntity = Positionen.class)
private Set<Positionen> positionen;
Child Class Positionen
@ManyToOne
@JoinColumn(name = "WF_REF_ID", referencedColumnName = "ID")
private WFData wfData;
Now I want to create an EJB session bean with a method which returns an object of type WFData (parent) published as web service . When I try to deploy the web service I get the following error message: Unable to generate serialization framework for web service
Does anyone know how to serialize a one-to-many relationship so I can use these objects in a web service?
Best regards,
KevinI found the solution to get serialization correctly working and enable the service to be used in Visual Composer.
You need to add the tag @XmlTransient to the getter method of the attribute in the child class that references the parent.
@XmlTransient
public WFData getWfData() {
return wfData; -
Using data from one-to-many relationship
Hi,
i have an one-to-many relationship among two tables similar to the structure as in the below reference:-
[One-to-many-reference|http://docs.oracle.com/cd/E23507_01/Platform.20073/RepositoryGuide/html/s1204repositoryexamplefonetomanymappi01.html]
taking this as an example, i have the city's name with me. using this data in the addr_tbl in the 'address' item-descriptor, i need to get the value of the 'name' in the usr_tbl in the 'user' item descriptor. i will have the list of 'city' with me which i have to iterate and display the corresponding 'name'.
will i be able to perform this in the jsp itself or does it have to be done in java? a sample code snippet or reference for doing this will be of much help.
thank you.Thanks a lot, Sheik.
if i have to do the reverse, ie for the 'name' in the usr_tbl of user item-descriptor i have to fetch the 'city' values in the addr_tbl, will it suffice if i do the following?
<dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
<dsp:param name="queryRQL" value="name=\"sirius\""/>
<dsp:param name="repository"
value="/com/MyRepository"/>
<dsp:param name="itemDescriptor" value="user"/>
<dsp:oparam name="output">
<dsp:valueof param="element.address.city"/>
</dsp:oparam>
</dsp:droplet> -
How do I create a One to many relationship page in Dreamweaver?
How do I create a page in dreamweaver that comes up after the user logs in from the log in page that will allow the user to:
Add, change and delete in 2 tables that are in my MYSQL database that is a one to many relationship
One thing that is confusing is how the foreign key that links to the one side of the relationship is created in the many side without the user inputting the foreign key each time adding information to the many side table.
I am creating this in Dreamweaver using a MYSQL database and PHP.>Would the following be a part of it:
>
>Outer join
Probably not. When updating/inserting/deleting from 2 tables you perform each seperately. Table updates may join two or more tables to resolve the correct row(s) but you still only update one table at a time. Procedurally you would create a transaction, update the first table, update the second table and then commit the transaction.
EDIT: Well I take back my last comment. I see that MySQL does seem to support multiple table updates. I don't use MySQL so I can't really help you on that but the MySQL manual gives pretty clear syntax. -
ODI Interface - One to many Transactional table to Flat Table
Hi,
In my transactional system I have two tables Program and Program Details, Program and Program Details is one to many relationship. I need to create a target table with few columns from Programs and all columns from Program Details as a flat target table, please let me know how to design the interface. Thanks for your time and help.HI,
create a data store with required columns
and specify the file format as filename.txt at resource name(available at definition tab in data model) then your target will be created at yout logical schema path.
Thanks,
Swaroopa
Edited by: 989684 on Mar 7, 2013 9:03 PM -
Newbie: one to many relationship SQL error
Greetings all-
This is probably a slam dunk for you JDO experts. I'm a JDO newbie, working
with an existing schema in MySQL. I have a one to many relationship between
two tables:
Table "company":
Fields:
company_id: int(11) -- primary key
name : varchar(64)
division : varchar(64)
Table "company_products"
Fields:
company_id: int(11) -- foreign key to table company
product_name: varchar(64)
product_description: varchar(64)
So, I created the corresponding classes:
public class Company {
private int companyID;
private String company_name;
private String division;
// Array of CompanyProduct
private ArrayList companyProducts;
// .. methods omitted
public class CompanyProduct {
private int companyID;
private String productName;
private String productDesc;
// Methods omitted
Then I created the "package.jdo" file:
<?xml version="1.0"?>
<jdo>
<package name="com.packexpo.db">
<class name="Company">
<extension vendor-name="tt" key="table" value="company"/>
<extension vendor-name="tt" key="pk-column" value="company_id"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="companyID">
<extension vendor-name="tt" key="data-column" value="company_id"/>
</field>
<field name="name">
<extension vendor-name="tt" key="data-column" value="name"/>
<extension vendor-name="tt" key="column-length" value="64"/>
</field>
<field name="division">
<extension vendor-name="tt" key="data-column" value="division"/>
<extension vendor-name="tt" key="column-length" value="64"/>
</field>
<field name="companyProducts">
<collection element-type="com.packexpo.db.CompanyProduct"/>
<extension vendor-name="tt" key="inverse" value="companyID"/>
</field>
</class>
<class name="CompanyProduct">
<extension vendor-name="tt" key="table" value="company_product"/>
<extension vendor-name="tt" key="pk-column" value="company_id"/>
<extension vendor-name="tt" key="lock-column" value="none"/>
<extension vendor-name="tt" key="class-column" value="none"/>
<field name="companyID">
<extension vendor-name="tt" key="data-column" value="company_id"/>
</field>
<field name="productName">
<extension vendor-name="tt" key="data-column" value="product_name"/>
<extension vendor-name="tt" key="column-length" value="64"/>
</field>
<field name="productDesc">
<extension vendor-name="tt" key="data-column"
value="product_description"/>
<extension vendor-name="tt" key="column-length" value="64"/>
</field>
</class>
</package>
</jdo>
Enhancement works fine. I successfully query and retrive Company objects
from the database, but as soon as I try to get the list of CompanyProducts,
I get an SQL Error:
javax.jdo.JDODataStoreException: [SQL=SELECT company.COMPANYPRODUCTSX FROM
company WHERE company.company_id = 82061]
E0610 Error in executeQuery()
E0606 executeQuery() error --
E0701 Error in getResult().
E0708 Command results in error - 1054 Unknown column
'company.COMPANYPRODUCTSX' in 'field list'
NestedThrowables:
com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
company.COMPANYPRODUCTSX FROM company WHERE company.company_id = 82061]
E0610 Error in executeQuery()
E0606 executeQuery() error --
E0701 Error in getResult().
E0708 Command results in error - 1054 Unknown column
'company.COMPANYPRODUCTSX' in 'field list'
I know i have probably set up the package.jdo file incorrectly, but I'm at a
loss for what I did wrong.
Any suggestions?
Thanks!
-MikeHi,
915766 wrote:
I need to write sql for below requirement:
table structure is
serial no LPN
1 4
2 4
3 6
4 6
5 6
6 3
7 3
8 3
9 1
I have to pick distinct 'LPN' like below:That sounds like a job for "GROUP BY lpn".
(any serial no can be picked for the distinct LPN)It looks like you're displaying the lowest serial_no for each lpn. That's easy to do, using the aggregate MIN function.
results needs to be as below:
serial no LPN
1 4
3 6
6 3
9 1
Please suggest with sql.Here's one way:
SELECT MIN (serial_no) AS serial_no
, lpn
FROM table_x
GROUP BY lpn
ORDER BY lpn -- if wanted
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
One to many relationship leads to recursion?
Hi,
I've created a web services function which returns an object retrieved from a database using the persistence api (the class was generated by the Netbeans 5.5 "Entity Class from Database" feature.
I can successfully return an object which has no foreign keys. However, when I try to retrieve an entity which is on either side of a 1:N relationship, I receive a stackOverflowError.
Here's my sample schema (I'm using Derby bundled with SJAS 9 for testing)
create table Address (
Id int not null,
StreetName varchar(255),
City varchar(255),
PostalCode varchar(255),
Party int,
primary key (Id)
create table Party (
Id int,
Name varchar(255),
primary key(Id)
alter table Address add constraint foreign key (Party) references Party;So as you can see, one Party might have many addresses.
I can retrieve either an Address or Party from the database using something like:
em.createNamedQuery("Party.findById")
.setParameter("id", 1)
.getSingleResult();When I try to return it, I get a stackOverflowError in the server log. I'm using the default Toplink provider so enabling full logging on this, I can see the SQL.
When retrieving an address, it selects all of the address fields and correctly binds the supplied Id value. It then performs a select on the Party table using the Address.Party value. This in turn causes it to attempt to retrieve an Address. After three queries, the error is thrown.
I can't see why the above schema should cause this problem. Where an Address is requested, I would expect it to retrieve the address fields, including the value of the Party field but not the Party object itself. On the other hand. when a Party is retrieved, I would expect it to recurse through and return a collection of Address objects.
Have I misunderstood this or am I missing some fundamental point about JAX-WS?
Thanks for your help,
-PhilYou have to set both sides of the relations...
for example to do this in a more seamless manner:
public UserProfile
public void addLog (UserActivityLog activity)
logs.add (activity);
if (!equals (activity.getUserProfile ()))
activity.setUserProfile (this);
Now this is the most primitive of ways to maintain two sided relations.
There are a lot of other patterns to get around this.
If you want to set the UserActivityLog to a specific UserProfile without
having a firm reference to ther UserProfile, you should get the object
from the database/persistenceManager... as you are using application
identity, you can do something like pm.getObjectById.
JDO does not do magic references. If you set something to null, it will
remain null until you set it.
Srini wrote:
Hi Guys
I am trying to create a one to many relationship between 2 JDOs.
UserProfile - User JDO having user info
UserActivityLog - JDO having user log info
UserProfile -- UserActivityLog
1 many
UserProfile - has a collection of UserActivityLog objects
UserActivityLog - has a reference to UserProfile
Qn 1:
I created a UserProfile along with a collection of 2 UserActivityLog
objects.
Navigation:
Now given a UserProfile object,i am able to get the UserActivityLog objects.
But given a UserActivityLog object ,i get a NULL UserProfile object.
Issues:
Why this is happening???Do i need to set the reference for "UserProfile" in
UserActivityLog before inserting???
If so,then how do i add a UserActivityLog to an existing
UserProfile???cos,if i create a UserActivityLog with reference to
UserProfile ,then it will throw a Duplicate Key violation for UserProfile as
it is already persisted in DB.
It will be great if you can direct me to some one to many relationship
examples already implemented.
Thanks
Srini
Stephen Kim
[email protected]
SolarMetric, Inc.
http://www.solarmetric.com -
One to Many Relationship Issue
Post Author: jmb1977
CA Forum: Formula
I am having a problem in which I have a one to many relationship with contact phone numbers and students. In other words, one student can have multiple contacts. (I work for a school district)
I made up two formulas...called Contact1Phone and Contact2Phone.
Here is the code I use to display the data:
IF {STUDCTCT.CNTNUMBER} in ["C1"] THEN STDUCTCT.CNTWPHONE
Then the other formula does the same, except uses "C2".
What I get is either C1 or C2 displays, but never both for the same student. Anyway to make this work? Any help on this would be greatly appreciated!Post Author: jmb1977
CA Forum: Formula
I forgot to add, I do know that placing STUDCTCT.CNTNUMBER in [C1,C2] as a selection then just simply place the CNTWPHONE field into the details section of the report will give me the results. But the reason why I am trying it the other way is that I can export the data as one record per student, thus I am trying to put the fields and formulas into the group section. -
One to many relationship in hibernate
I am very much new to hibernate,
for testing purpose I am using JPA annotations and hibernate.
While testing one to many relationship , I got a problem
I have a PurchaseOrder class and OrderLine class having one to many relationship.
package orderpackage;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class PurchaseOrder {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@OneToMany(cascade=CascadeType.ALL,mappedBy="order")
private List <OrderLine> orderLine = new ArrayList<OrderLine>();
public PurchaseOrder(String orderName) {
this.orderName = orderName;
public List<OrderLine> getOrderLine() {
return orderLine;
public void setOrderLine(List<OrderLine> orderLine) {
this.orderLine = orderLine;
private String orderName;
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getOrderName() {
return orderName;
public void setOrderName(String orderName) {
this.orderName = orderName;
OrderLine.java
package orderpackage;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
@Entity
public class OrderLine {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private String itemName;
private int qty;
@ManyToOne(cascade=CascadeType.ALL)
private PurchaseOrder order;
public OrderLine(String itemName, int qty) {
this.itemName = itemName;
this.qty = qty;
public PurchaseOrder getOrder() {
return order;
public void setOrder(PurchaseOrder order) {
this.order = order;
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getItemName() {
return itemName;
public void setItemName(String itemName) {
this.itemName = itemName;
public int getQty() {
return qty;
public void setQty(int qty) {
this.qty = qty;
OrderTest.java
package orderpackage;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class OrderTest {
public static void main(String[] args) {
PurchaseOrder order = new PurchaseOrder("order no 1");
OrderLine orderLine1 = new OrderLine("item1",25);
OrderLine orderLine2 = new OrderLine("item2",28);
OrderLine orderLine3 = new OrderLine("item3",38);
OrderLine orderLine4 = new OrderLine("item4",48);
order.getOrderLine().add(orderLine1);
order.getOrderLine().add(orderLine2);
order.getOrderLine().add(orderLine3);
order.getOrderLine().add(orderLine4);
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
session.persist(order);
session.getTransaction().commit();
session.close();
I can see Order and Order Line are get persisted but Order Line table don't have order_id populated automatically. Please help me out.That is because you're not setting it, obviously. Nowhere in your code are you actually populating the order property of the orderlines.
-
I'm a bit confused on how to create one to many relationships with ADF. Let's say I have a make and model table. One make can have many models. Now let's say I create a Business Facade like this (I'm using JavaBeans):
public Collection getMakes () { ... }
Ok, my data control now has the collection for makes. And I want to do something like this
public Collection getModels (Make make) { ... }
I can't make this work because ADF will detect it as a method accesor. How does this work?
Regards,
Néstor BoscánMaybe looking at how TopLink does it, can help you.
Try creating TopLink objects for a master detail set of tables (dept-emp).
This will create two beans that should be similar to your beans. Look at their structure to see how they work.
The ADF TopLink workshop has the steps to show you how to do this.
http://www.oracle.com/technology/obe/obe9051jdev/ide1012/adfworkshop/buildingadfapplicationsworkshop.htm
Maybe you are looking for
-
i am looking to buy an ipad 2 or the new ipad (preferably 32gb) but dont want to buy the 3G version as i have unlimited data usage in my mobile phone plan, i know the wifi only ipad is generally cheaper, but i was wondering if there was a way to buy
-
Constant kernel panics while using iPhoto 11
I'm hopeful that someone can help me sort this out....it's getting very frustrating. It doesn't "just work"....not anymore. First off, I'm using an early 2009 (unibody) 17" MBP, 2.93 GHz, fully loaded (for this model) with 8GB RAM, 750 GB HDD with pl
-
How do you get the lady on ipad to stop talking?
Now there is a lady talking and saying evrything i am doing on ipad, how do i turn her off? also it seems like its harder to open and slide the screen.
-
FEBAN - list of bank statements per year
Hello, running transaction FEBAN; in the overview as from now, we have the bank statements of last year and this year altogether in one list, which may be confusing. Is there any way to change the view, so that we have an overview per year? Is it abs
-
Error installing OBI EE on Dell XP
Hi all, I am trying to install OBI EE on my laptop (Dell Lattitude 630 / XP). Right after clicking set up.exe I get a message that my platform is not supported and then it lists the supported platforms. Looking at this forum I saw some people having