- This topic has 3 replies, 2 voices, and was last updated 13 years, 5 months ago by jkennedy.
-
AuthorPosts
-
Smitht19MemberI have a project with one table I used Spring Scaffolding on. I am getting this error
null entities are not supported by org.hibernate.event.def.EventCache
I have an created_on and created_by fields on the table that can’t be Null. I have created a oracle trigger to populate both before insert but I am still getting this error. Do I need to make a change to my DOMAIN bean for the table for thoses fields.
Smitht19Member@Smitht19 wrote:
I have a project with one table I used Spring Scaffolding on. I am getting this error
null entities are not supported by org.hibernate.event.def.EventCache
I have an created_on and created_by fields on the table that can’t be Null. I have created a oracle trigger to populate both before insert but I am still getting this error. Do I need to make a change to my DOMAIN bean for the table for thoses fields.
I changed the fields so they could be null and my trigger does not seem to work
CREATE TABLE NEWS
(
NEWS_ID NUMBER(10) NOT NULL,
DESCRIPTION VARCHAR2(1000 BYTE) NOT NULL,
BEGIN_DATE DATE NOT NULL,
END_DATE DATE NOT NULL,
CREATED_BY VARCHAR2(30 BYTE),
CREATED_ON DATE,
MODIFIED_BY VARCHAR2(30 BYTE),
MODIFIED_ON DATE,
WORD_COLOR VARCHAR2(40 BYTE)
)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;CREATE UNIQUE INDEX NEWS_PK ON NEWS
(NEWS_ID)
LOGGING
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;CREATE OR REPLACE TRIGGER TR_NEWS_UPDATE
BEFORE UPDATE
ON NEWS FOR EACH ROW
BEGIN
:new.modified_by := USER;
:new.modified_on := SYSDATE;
END TR_NEWS_INSERT;
/
SHOW ERRORS;CREATE OR REPLACE TRIGGER tr_news_created
BEFORE INSERT
ON NEWS
FOR EACH ROW
BEGIN
DECLARE
NEXTVAL INTEGER;
username CHAR (20);
currdate DATE;
BEGIN
IF :NEW.news_id IS NULL
THEN
SELECT news_seq.NEXTVAL, USER, SYSDATE
INTO NEXTVAL, username, currdate
FROM DUAL;/* Set NEW.VALUES */
:NEW.news_id := NEXTVAL;
:NEW.created_by := username;
:NEW.created_on := currdate;
END IF;
END;
END tr_news_created;
/
SHOW ERRORS;
Smitht19MemberThe trigger does work is I add a record a Toad
jkennedyMemberIn the resources folder there should be a file that ends in -dao.properties.
There is a property in this file called show_sql.
Please set it to true and rerun it to see if you can see the sql statements in the console window for the server that might give you clues as to what the Hibernate layer is doing when creating or inserting your Entity.
Can you please also describe the steps you are taking prior to the exception.
Are you running the application and clicking on the link to create a new instance of your Entity, filling in data, and then saving?
Are the non null fields in the edit screen?Thanks for any additional details.
Jack -
AuthorPosts