<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tarek Moustafa</title>
    <description>The latest articles on DEV Community by Tarek Moustafa (@tarekottey).</description>
    <link>https://dev.to/tarekottey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F353587%2F3f1fc9ee-13f2-4c35-84a0-344905a5f964.jpeg</url>
      <title>DEV Community: Tarek Moustafa</title>
      <link>https://dev.to/tarekottey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tarekottey"/>
    <language>en</language>
    <item>
      <title>JPA ManyToOne Exception</title>
      <dc:creator>Tarek Moustafa</dc:creator>
      <pubDate>Sat, 21 Mar 2020 14:27:26 +0000</pubDate>
      <link>https://dev.to/tarekottey/jps-manytoone-failure-cnk</link>
      <guid>https://dev.to/tarekottey/jps-manytoone-failure-cnk</guid>
      <description>&lt;p&gt;I have the following entities:&lt;/p&gt;

&lt;p&gt;@Entity&lt;br&gt;
@Table("table_x")&lt;br&gt;
public class X{&lt;/p&gt;

&lt;p&gt;&lt;a class="comment-mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;
&lt;br&gt;
@GeneratedValue(strategy = GenerationType.IDENTITY)&lt;br&gt;
private Long id;&lt;/p&gt;

&lt;p&gt;@ManyToOne&lt;br&gt;
private Y y;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;@Entity&lt;br&gt;
@Table("table_y")&lt;br&gt;
public class Y{&lt;br&gt;
&lt;a class="comment-mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;
&lt;br&gt;
@GeneratedValue(strategy = GenerationType.IDENTITY)&lt;br&gt;
private Long id;&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;@Repository&lt;br&gt;
public interface XRepository extends JpaRepository, JpaSpecificationExecutor{&lt;br&gt;
@Query(value= "select x.* from X x where x.y in :yList")&lt;br&gt;
List getX(List yList);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;when trying to call getX from XRepository while table_y is empty it throws:&lt;br&gt;
Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception.&lt;/p&gt;

&lt;p&gt;could not extract ResultSet; SQL [n/a]&lt;/p&gt;

&lt;p&gt;if table_y has records in the database, everything works fine&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
