OneToMany resulting in null field.
I'm attempting to implement the code example from the NetBeans magazine (Nov 2006) using NetBeans 6.0 beta 2 with glassfish-v2 -b58g. It's using a simple db structure with 3 tables:
[Platform] ---- [JSR] 1----* [Package]
I'm running into a problem with the 1 to many between JSR and Package.
The end result is that the jsr field in the inserted Package row is null.
Here's the JSR class (relevant pieces only, hopefully)
@Entity
public class JSR implements Serializable
private List<Package> packages;
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL,
mappedBy="jsr")
public List<Package> getPackages()
return packages;
public void setPackages(List<Package> packages)
this.packages = packages;
Here's the Package class
@Entity
public class Package implements Serializable
private JSR jsr;
@ManyToOne
public JSR getJsr()
return jsr;
public void setJsr(JSR jsr)
this.jsr = jsr;
Here's the code from a session bean that enters the data:
@Stateless
public class JavaPlatformManagerBean
implements JavaPlatformManagerRemote,
JavaPlatformManagerLocal
@PersistenceContext
private EntityManager em;
public void createPlatform(Platform platform)
em.merge(platform);
The code that calls the session bean (from a jsp backing bean)
public class JPMClient
@EJB
private JavaPlatformManagerRemote jpm;
public void createJavaSE()
JSR jsr1 = new JSR(176,
"Java SE 5 Release Contents",
new Package ("java.lang"),
new Package ("java.util"),
new Package ("java.sql"));
JSR jsr2 = new JSR(166,
"Concurrency Utilities",
new Package ("java.util.concurrent"));
Platform platform = new Platform ("Java SE 5", jsr1, jsr2);
jpm.createPlatform(platform);
And the results of quering the table (in Derby)
PACKAGE JSR_NUM
java.util.concurrent NULL
java.sql NULL
java.lang NULL
java.util NULL
I know this is long winded, but what am I missing in the JSR/Package classes such that the relationship back to the JSR is null?
Thanks for any insight.
GregM
Unfortunately, AMF serialization is something of a black art. I'd run into multiple issues in the past (working with Granite DS, rather than Blaze--but it's essentially the same thing). I'm not sure about Blaze, but Granite has very verbose logging available if you configure log4j to DEBUG level for org.granite. The other alternative is to attach to your Java process with a debugger (Eclipse makes this fairly automagical), download the Blaze source and configure Blaze as a project in Eclipse, add it to source lookup for your project, and step through the actual serialization to see what's going on. This is moderately complicated to set up, but priceless when it comes to debugging.
Similar Messages
-
Mapping failure in Null fields passing
Hi
We are facing some problem in null fields passing to RFC side.. some times the JDBC colums not having the data ,
so that time our map is failing to call RFC.
Please let me know any prevent methodologies for this?
Target side field occurances are 0...1
Regards
rambarkiHi Rambarki,
since your target field is optional, you can map your target only if the value is present in the source, do not map if it is null.
Also are you getting any specific error ?
Have a look at this thread aswell..
JDBC Adapter: Mapping: result contains only null values
Regards
Anand -
Union reporting involving null fields.
Hello ALL;
I'm new to OBIEE and the following is a query on 10g.
I use the union reporting using dummy/null fields as the Subject areas are built in a way that they don't include all fields one report would need at my work place.
(Let me know if I could work otherwise)
Suppose I have a, b fields from S1 and c from S2, I implement the following approach:
S1 a b 0
S2 a 0 c
What I expect to see is:
Result a b c
What I see is:
Result a b 0
a 0 c
I see two records with one ID(feild a).
Could anyone help me on this, please?
Thanks,
-RBGoto Table View in the answers, change result column formula to avg(saw_1 by saw_0).
-
I wasn't very sure how to title this thread.
I need to restrict Opening Amount to a single period while showing all periods for Activity Amount.
I have:
Demensions:
Fiscal Year
Business Unit
Fund Code
Fiscal Period No
Fiscal Period No
GL Acc No
Gl Acc Description
Facts:
Opening Amount
Activity Amount
Prompts (Created under the Prompts Tab):
Fiscal Year
Business Unit
Fund Code
Modified Column Formula:
Opening Amount:
CASE FILTER("Facts - GL Balance"."Opening Amount" USING ("Time"."Fiscal Period Number" = 1)) WHEN 0 THEN null ELSE FILTER("Facts - GL Balance"."Opening Amount" USING ("Time"."Fiscal Period Number" = 1)) END
When Running the analysis I choose the following values for my prompts:
Fiscal Year: 2011
Business Unit: 33701
Fund Code: 49000
Results are returned as i'd wish except for:
I only want period 1 for Opening Amount
I only want Period 999 for Closing Amount
Both are the same problem.
I need to restrict Opening Amount to be shown by a single period.... while still showing Activity Amt by all periods.
The following URL takes you to a photobucket screenshot with descriptions. It is the fields "Undesired NULL Fields" I would like to get rid of.
http://s813.photobucket.com/user/lancesimmons/media/OpAmt_zpsc08be671.jpg.html#/user/lancesimmons/media/OpAmt_zpsc08be671.jpg.html?&_suid=1377704247312024937668844449184
Just a heads up, creating filter: 'Opening Amount is not equal to/is not in' restricts the Activity Amount to the first period.
Any suggestions?Hi,
Modify your XSL as below:
<xsl:for-each select="/ns0:Employee">
<tns:FirstName>
<xsl:value-of select="ns0:FirstName"/>
</tns:FirstName>
<xsl:if test='string-length(normalize-space(ns0:MiddleName))>0'>
<tns:MiddleName>
<xsl:value-of select="ns0:MiddleName"/>
</tns:MiddleName>
</xsl:if>
<tns:LastName>
<xsl:value-of select="ns0:LastName"/>
</tns:LastName>
</xsl:for-each> -
Issue with Duplicate Results and Summary Fields
My report is based on an Access Database. For the purposes of this current issue, there is the Master Table called u201CCnu201D and then a related u201CTable Au201D which includes multiple records related to the Master and also a related u201CTable B,u201D also with multiple records related to the Master.
For my report, I want to output results from Table B based on criteria in Table A. This naturally produces duplicate output on the report. As a result, the Summary Fields that I want to include are incorrect.
I have tried multiple combinations of the Select Distinct function, suppression based on u201Cprevious fieldu201D being equal, summary fields, running totals and if-then statements and still cannot find a solution that works in all of the cases involved.
Below are descriptions of three different scenarios that are occurring:
EXAMPLE #1: Entry 1 has 2 records in Table A and 2 Records in Table B so "Select Distinct" including the Table B ID # and then a Summary Field for the Total produces the correct results, while a Running Total is Incorrect.
EXAMPLE #2: Entry 2 has 2 records in Table A and 1 Record in Table B so a suppression formula of the field based on the "Previous =" Table B ID # and the Running Total produce the correct results, while Summary Field is incorrect.
EXAMPLE #3: Entry 3 has 6 records in Table A and 6 Records in Table B. Neither Summary or
Running Totals produce correct results.
I would greatly appreciate any advice in terms of creative formulas, etc. that would help produce correct results here.
Iu2019ll be pulling my hair out soon! Thanks so much-Hi Berry
Try to create a command with a subquery. The subquery will be returning the the duplicate records and the main query that uses this subquery will find distinct records out of the resultset returned by the subquery.
Let me know if this helps.
Regards
Nikhil -
SQL Query -How2bring multiple results into one field using Formatted Search
Hi Everyone
i am trying to bring in the results of the field dbo.Lot_ITEM.LOT using a formatted search into a row level using the following query:
SELECT dbo.LOT_ITEM.LOT
FROM dbo.DLN1 INNER JOIN dbo.LOT_ITEM ON dbo.DLN1.ItemCode = dbo.LOT_ITEM.ITEM
WHERE dbo.LOT_ITEM.ITEM=$[DLN1.ItemCode]
however the result of the dbo.Lot_ITEM.LOT field could be more then one value depending on how many lots are assigned for that item
(for example this query would be similar to assigning batch/serial numbers to an item being despatched - as you can choose multiple batches/serials depending on the quantities available and required and then move from the left to the right side of the selection window) if that makes sense!
is it possible to bring in the multiple results into one field? and how can i amend the above query to include this?
Thankyou in advance :o)
Edited by: Asma Bi on Apr 23, 2008 7:22 PM
Edited by: Asma Bi on Apr 23, 2008 7:24 PMHi Suda
Thanks for replying :o) but im not sure about the query?
just to simplify it (as the query im working with is to do with 3rd party addons) i have used the serial/batchs field instead and used standard demo database fields from SBO 2005 sp01:
SELECT dbo.ixvSerialNoFact.SRI1_IntrSerial
FROM dbo.DLN1 INNER JOIN
dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
WHERE dbo.ixvSerialNoFact.ItemCode='g1000' and dbo.ixvSerialNoFact.SRI1_BaseEntry = '193'
The above brings me the relevant results but when i change it to be used in a formatted search:
SELECT dbo.ixvSerialNoFact.SRI1_IntrSerial
FROM dbo.DLN1 INNER JOIN
dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
WHERE dbo.ixvSerialNoFact.ItemCode=$[dln1.itemcode] and dbo.ixvSerialNoFact.SRI1_BaseEntry = $[dln1.DocEntry]
i cant seem to get it to work - now this may be because the serial number is not allocated until teh record is added to the system, however when this happens i am unable to go back in and manually trigger the query as the delivery note rows cannot be selected!
i think as what im originally wanting an answer for is same as this example, im wanting to know if this is even possible?
Thanks
Edited by: Asma Bi on Apr 24, 2008 3:53 PM
Edited by: Asma Bi on Apr 24, 2008 3:55 PM -
Hello techies,
I am doing simple program, which is connecting to mysql server and retreiving the results from my database using servlets.
I want to do if the result set is returning zero rows i.e if there is no matching rows is available in the table, which i had specified in my query.
Here is my code
String url = "jdbc:odbc:testDSN";
Properties p = new Properties();
p.put("user", "root");
p.put("password", "kkkk");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url, p);
System.out.println("connection established");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select *from test.emp where empNumber =15");
System.out.println("resultset is null" + rs.wasNull());
if (rs.getRow() == 0) {
System.out.println("nomatching subject is found");
out.println("No Matching subject is found");
else {
out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
out.println("<TR><TH>eno</TH><TH>ename</TH><TH>date</TH></TR>");
// Loop through results of query.
while (rs.next() == true)
out.println("<TR>");
out.println("<TD>" + rs.getString("eno")+ "</TD>");
out.println("<TD>" + rs.getString("ename") + "</TD>");
out.println("<TD>" + rs.getString("date") + "</TD>");
out.println("</TR>");
Here if there are no employe record matching eno =15 in my table then i want to print no matching record is found.
where i am making mistake??
plz help me .
It is very urgent.
Thanks (inadvance)
regards,
ramuGood Lord, you have database and HTML generation code in the same method?
This is not the way to do JDBC code. Start with a tutorial.
Ever read about object-oriented programming? How 'bout starting with an Employee class that has id, name, and date (what date? birth date? employment date? termination date?) as attributes. Then write a data access object that can do all the database stuff on Employee's behalf, without any consideration for UI. Test that on the command line until you have it working perfectly. THEN worry about how you'll display results to the user.
Your JDBC code isn't right. wasNull() checks to see if the column result is null, not the result set itself. (ResultSet can never be null; read the javadocs). You'd be getting a NullPointerException if ResultSet was null, wouldn't you?
Your code deserves a SERIOUS rewrite, which I'm not inclined to do for you. But I would recommend something more along these lines:
// hardwired url, driver, and query? oh, my - that's bad.
String url = "jdbc:odbc:testDSN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp where empNumber =15");
// you're obviously putting this in a servlet - bad idea.
// ever heard of JSPs?
out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
out.println("<TR><TH>eno</TH><TH>ename</TH><TH >date</TH></TR>");
// Loop through results of query.
while (rs.next())
out.println("<TR>");
out.println("<TD>" + rs.getString("eno")+ "</TD>");
out.println("<TD>" + rs.getString("ename") + "</TD>");
out.println("<TD>" + rs.getString("date") + "</TD>");
out.println("</TR>");
}% -
How can L identify what are the not null fields of a table in a stored procedure ?
How can L identify what are the not null fields of a table in a stored procedure ?
You could query the data dictionary:
SELECT column_name
FROM all_tab_columns
WHERE owner = '...'
AND table_name = '...'
AND nullable = 'N' -
Result of Calculated Field as Criteria?
I'm using CASE and CAST to convert a field to datetime format so that I can account for null field values
CASE
WHEN ISDATE([Date])=0 THEN 01/01/1900
ELSE
CAST([Date] as datetime)
END as [DateConverted]
How can I use this new [DateConverted] field in the criteria of my query so that I can only get records in a specific date range?I prefer using the below approach for date range comparison
DECLARE @tmp TABLE (Id INT IDENTITY(1,1),[Date] VARCHAR(20))
INSERT @tmp SELECT 0
INSERT @tmp SELECT GETDATE()-1
INSERT @tmp SELECT GETDATE()
INSERT @tmp SELECT GETDATE()+1
--SELECT * FROM @tmp
SELECT * FROM (
SELECT Id,CASE
WHEN ISDATE([Date])=0 THEN 01/01/1900
ELSE CAST([Date] AS DATETIME)
END [DateConverted]
FROM @tmp ) tmp
WHERE [DateConverted] >='1900-01-01'
AND [DateConverted] <'2014-01-05'
Reason being there's a small chance of some records getting wrongly excluded/included when you use BETWEEN clause especially when datetime field stores time part also.
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Hi all,
Ive configured an IDOC-to-File scenario with the IDOC MATMAS. The file generated uses the nl as the record delimiter and #! as the field separator. Everything works fine except when the IDOC has null fields. In these cases the communication channel does not write these fields because they are not in the XML message and then the structure within the file is bad. I need to write the entire fields even if they are not in the XML-IDOC. I found the mapping function mapWithDefault but there are a lot of fields to map. Is there any other solution to force Comunication Channel or the mapping process to write all the fields even if they have null values?
Thank you in advance!You shud map all the necessary fields manually using the graphical mapping for instantiating the fields on the target.
Regards,
Kittu. -
In WebI report, is that possible to show ZERO in NULL fields?
in WebI report, is that possible to show ZERO in NULL fields? crystal report has no issue, but i could not find a way to set ZERO to NULL field
can you tell?Bram,
This formula you used above is corrcet but is returning you a character '0' and when a descending sort is applied character values will be at the top.
So , apply the formula 'ToNumber' on the value returned form the above formula :-
ToNumber(above formula)
And then it will change 0 to number and give you the exact sort order.
Thanks,
Rohini Haksar -
Result of XML fields cannot be bold?
Hi all,
When i load XML data in my RTF file the output result of some fields are not bold. I check the RTF and every field i want in BOLD is clicked to be bold.
How is this possible?
Thanks in advance,
Konska.Hi,
Result from document properties->fonts of the generated PDF :
Albany WT J(Embedded Subset)
Type: TrueType(CID)
Encoding:Identity-H
Helvetica
Type:Type1
Encoding: Ansi
Actual Font:ArialMT
Actual Font Type: TrueType
Helvetica-Bold
Type: Type1
Encoding:Ansi
Actual Font: Arial-BoldMT
Actual Font Type: TrueType
Thanks,
Konska. -
Is it possible to avoid the wrapping for the NULL fields in a table (in Plus33)?
The fields above or below which have values look OK but the NULL fields are wrapped, thus making it hard to read.
Thanks!
Stefan BargaoanuDear James,
Thank you for your help. This works indeed but it means that I have to use 'column' for each column that may pose problems.
In the end, I think that this would be cumbersome.
I'll just leave the columns as they are and stick to the 'select * from table_name', without formatting each column.
Thanks!
Stefan -
How do I put a label in a null field in the result set of a group-by query
I run the query:
select section, count(*) from nparcel group by section
and get the result
section1 100
section2 200
section3 300
400
I would like to modify the query to put a label, perhaps 'BLANK', in the last returned row. Is that possible and if so how.
Thanks in advance for helping.Hi,
In SQL*Plus you have some additional options, that apply to all queries until you override them or end the session.
COLUMN section NULL BLANKapplies only to the column called "section".
SET NULL BLANKApplies to all columns. -
How can the query results include null if it's a required field on the front end?
I executed a query that simply asked for all data points on a single table.
I am trying to figure out why the query would report back as having all "Null" values in 3 of 10 columns. The information is required for the end user to enter before the system allows
them save a record.You understand correctly.
When you look up de service code do you get an description from table DDLValues?
THIS IS CORRECT
If the service code is in there, you should check why de ID is not correct.
I dont know what this means. Check why the "ID" is not correct? What ID?
The DDLvalues table has no objects on which it depends. It that normal?
This is the code for the individual services
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[IndividualService](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[StudentID] [uniqueidentifier] NULL,
[DateofService] [datetime] NULL,
[ServiceCode] [int] NULL,
[FocusCode] [int] NULL,
[InterventionCode] [int] NULL,
[ClinicianID] [uniqueidentifier] NULL,
[Schoolid] [bigint] NULL,
[Approved] [int] NULL CONSTRAINT [DF_IndividualService_Approved] DEFAULT ((0)),
CONSTRAINT [PK_IndividualService] PRIMARY KEY CLUSTERED
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_aspnet_Users] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Students] ([StudentID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_aspnet_Users]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_aspnet_Users1] FOREIGN KEY([ClinicianID])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_aspnet_Users1]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_DDLValues] FOREIGN KEY([FocusCode])
REFERENCES [dbo].[DDLValues] ([DDLValueID])
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_DDLValues]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_DDLValues1] FOREIGN KEY([InterventionCode])
REFERENCES [dbo].[DDLValues] ([DDLValueID])
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_DDLValues1]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_DDLValues2] FOREIGN KEY([ServiceCode])
REFERENCES [dbo].[DDLValues] ([DDLValueID])
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_DDLValues2]
GO
ALTER TABLE [dbo].[IndividualService] WITH CHECK ADD CONSTRAINT [FK_IndividualService_Schools] FOREIGN KEY([Schoolid])
REFERENCES [dbo].[Schools] ([SchoolID])
GO
ALTER TABLE [dbo].[IndividualService] CHECK CONSTRAINT [FK_IndividualService_Schools]
GO
Maybe you are looking for
-
iWork doesn't seem to recognize that I already have the pages, keynote, and numbers apps so I can't use iCloud to sync my documents. How to get my apps recognized?
-
Connection error in mail_logs
Hello, since some days I have a lot of entrys like this in my mail_logs: Tue Feb 12 12:23:31 2008 Info: Connection Error: DCID: 32131664 domain: 7-11.com IP: 199.196.10.25 port: 25 details: timeout interface: 192.168.0.10 reason: connection timed out
-
Keynote stops when playing and won't continue to next slide?
Keynote stops when playing and won't continue to next slide?
-
Tax is added / not added to material cost , How ?
Dear All , As we know that cond " JVRN " is non deductible i.e company will not get any credit for this tax paid & in P.O the tax will be added to material cost , in the same way cond " JVRD " is a deductible i.e the comp wi
-
Business Components and OAS 4.0.8
I have several projects running in JDeveloper - one of them being a BC4J project, the others a mix of servlets and classes that make use of the BC4J project to interact with the database. I have successfully managed to deploy the Business components