ramu11 commented on code in PR #27314: URL: https://github.com/apache/camel/pull/27314#discussion_r4215312342
########## components/camel-hibernate/src/main/java/org/apache/camel/component/hibernate/HibernateEndpoint.java: ########## @@ -0,0 +1,330 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hibernate; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.camel.Category; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriPath; +import org.apache.camel.support.EndpointHelper; +import org.apache.camel.support.ScheduledPollEndpoint; +import org.apache.camel.util.PropertiesHelper; +import org.hibernate.SessionFactory; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; + +@UriEndpoint(firstVersion = "4.24.0", scheme = "hibernate", title = "Hibernate", syntax = "hibernate:entityClassName", + category = { Category.DATABASE }, headersClass = HibernateConstants.class) +public class HibernateEndpoint extends ScheduledPollEndpoint { + + @UriPath(description = "Target entity class name or entity type name") + @Metadata(required = true) + private String entityClassName; + + @UriParam(description = "The HQL selection query to execute.", label = "producer,consumer") + private String selectionQuery; + + @UriParam(description = "The HQL mutation query to execute.", label = "producer") + private String mutationQuery; + + @UriParam(description = "The natural-id property values used for lookup. String values can use Simple expressions from the message.", + label = "producer", prefix = "naturalId.", multiValue = true) Review Comment: I verified this with Hibernate ORM 8.0.0.Beta3 using Long values for both a natural-id and a filter parameter. A String value such as "123" is not converted to Long by either find(..., KeyType.NATURAL) or Filter#setParameter(...) in these paths. The natural-id lookup fails during natural-id normalization, and the filter parameter is rejected because the value is not a Long. So the current URI-based configuration requires non-String typed values to be supplied through Java/#bean configuration. I haven't added implicit type conversion in Camel, since that would require resolving the target type from Hibernate metadata. I'll update the component documentation to make this limitation explicit and mention that typed natural-id/filter values should be configured through Java or #bean. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
