[jboss-jira] [JBoss JIRA] (DROOLS-10) Cannot use @timestamp annotation on a java.sql.Timestamp field when declaring metadata for an existing Java type

Edson Tirelli (JIRA) jira-events at lists.jboss.org
Tue Mar 12 14:54:42 EDT 2013


    [ https://issues.jboss.org/browse/DROOLS-10?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760667#comment-12760667 ] 

Edson Tirelli commented on DROOLS-10:
-------------------------------------

Unable to reproduce in 6.0.0.Alpha9. I added the following test case to the code base:

{code:title=javaSqlTimestampTest.java}
    @Test
    public void testJavaSqlTimestamp() {
        String rule = "";
        rule += "package " + Message.class.getPackage().getName() + "\n" +
                "declare " + Message.class.getCanonicalName() + "\n" +
                 "   @role( event ) \n" +
                 "   @timestamp( startTime ) \n" +
                 "   @duration( duration )\n" +
                "end\n";
        
        KnowledgeBase kbase = loadKnowledgeBaseFromString( rule );
        StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        Message msg = new Message();
        msg.setStartTime( new Timestamp( 10000 ) );
        msg.setDuration( 1000l );

        EventFactHandle efh = (EventFactHandle) ksession.insert( msg );
        assertEquals( 10000,
                      efh.getStartTimestamp() );
        assertEquals( 1000,
                      efh.getDuration() );
    }

    public static class Message {
        private Timestamp timestamp;
        private Long duration;

        public Timestamp getStartTime() {
            return timestamp;
        }

        public void setStartTime(Timestamp timestamp) {
            this.timestamp = timestamp;
        }

        public Long getDuration() {
            return duration;
        }

        public void setDuration(Long duration) {
            this.duration = duration;
        }
    }
{code}

I will close the ticket. If you are still having problems in 6.0, please reopen it with more details on how to reproduce it.

Thank you.
                
> Cannot use @timestamp annotation on a java.sql.Timestamp field when declaring metadata for an existing Java type
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: DROOLS-10
>                 URL: https://issues.jboss.org/browse/DROOLS-10
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>            Reporter: Ken Warkentyne
>            Assignee: Mark Proctor
>
> We have a Java class that uses java.sql.Timestamp to record time values. In Drools 5.0.1, we were able to use the @timestamp annotation as follows:
> {code}
> declare StateEvent
> 	@role( event )
> 	@timestamp( startTime )
> 	@duration( duration )
> end
> {code}
> StateEvent contains the following:
> {code}
> import java.sql.Timestamp;
> ...
>     private Timestamp startTime;
>     private Long duration;
>     public Timestamp getStartTime() {
>         return startTime;
>     }
>     public void setStartTime(Timestamp st) {
>         startTime = st;
>     }
>     public Long getDuration() {
>         return duration;
>     }
>     public void setDuration(Long d) {
>         duration = d;
>     }
> ....
> {code}
> We load the rules from a .drl file as follows:
> {code}
> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
> kbuilder.add(ResourceFactory.newClassPathResource("path-to-file", ResourceType.DRL);
> {code}
> In 5.4.0, this no longer works and we get the error message:
> {code}
> Annotated type StateEvent - undefined property in @annotation timestamp: java.sql.Timestamp.value();
> {code}
> Also tested with 5.5.0.Final and 5.5.0.CR1

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list