You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "sarada.ch" <sa...@gmail.com> on 2017/05/29 03:58:55 UTC

Camel hibernate issue with Select

Hi All,

I am using camel and below is the

<route id="_route1">
            <from id="_from1" uri="timer:foo?period=5s"/>
            <to id="_to1"
uri="hibernate:com.x.dto.ReferenceTable?consumer.namedQuery=selectQuery"/>
            <log id="_log1" message="selected ${body}"/>
        </route>

Refference Table

@Entity
@Table(name="REFFERENCE_TABLE")
@NamedQuery(name = "selectQuery", query = "select m from ReferenceTable m ")
public class ReferenceTable {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private String key;
	@Column
	private String value;
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
}

I am not sure why it inserts instead of search

com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value
NULL into column 'key', table 'Maxtest.dbo.REFFERENCE_TABLE'; column does
not allow nulls. INSERT fails.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-hibernate-issue-with-Select-tp5801204.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel hibernate issue with Select

Posted by Claus Ibsen <cl...@gmail.com>.
I suggest to use the jpa component instead. Its more maintained and
also part of Apache Camel.


On Tue, May 30, 2017 at 6:59 AM, sarada.ch <sa...@gmail.com> wrote:
> Working fine now but still feeling weird why they have restricted to and
> form.
>
> to: will insert
> from: will select/delete
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-hibernate-issue-with-Select-tp5801204p5801316.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel hibernate issue with Select

Posted by "sarada.ch" <sa...@gmail.com>.
Working fine now but still feeling weird why they have restricted to and
form. 

to: will insert 
from: will select/delete



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-hibernate-issue-with-Select-tp5801204p5801316.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel hibernate issue with Select

Posted by "sarada.ch" <sa...@gmail.com>.
After adding Identity to primary key the error is not displayed 

But for the below hibernate component it inserts rather than select 

<to id="_to1"
uri="hibernate:com.x.dto.ReferenceTable?consumer.namedQuery=selectQuery"/>



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-hibernate-issue-with-Select-tp5801204p5801206.html
Sent from the Camel - Users mailing list archive at Nabble.com.