问:
I want to get the result with multiple mysql db using spring
i want to get the result which are got two different DB using spring-boot but i got the error now Actually i can't find what is wrong..

VO.Dve code

```<code>package com.example.rest.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Table(name = "MART")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Dve {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String USER_ID;
    private Integer ID;

    public String getID() {
        return ID;
    }
}
</code>```

VO.LogVo

```<code>package com.example.rest.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;

@Entity
@Table(name = "log")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LogVo {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String put_date;
    private Integer SCNT;
    private Integer SENT_TOTAL;
    private Integer SCART;
    private Integer ST_TOTAL;
    private Integer Imby_tables_cnt;
    private Integer Alarm;
    private Integer Alert;
    private Integer Watch;
    private Integer TZ;
    private Integer Normal;
    private Integer Rating_sum;

    public Integer getSENT_TOTAL(){
        return SENT_TOTAL;
    }
}
</code>```

RestDbConfig

```<code>package com.example.rest;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

@Configuration
@EnableTransactionManagement

@EnableJpaRepositories(
        entityManagerFactoryRef = "entityManagerFactory",
        basePackages = {"com.example.rest.rec.repo"}
)

public class RestDbConfig {

    @Primary
    @Bean(name = "dataSource")
    @ConfigurationProperties(prefix = "db1.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }

    @Primary
    @Bean(name = "entityManagerFactory")
    public LocalContainerEntityManagerFactoryBean
    entityManagerFactory(
            EntityManagerFactoryBuilder builder,
            @Qualifier("dataSource") DataSource dataSource
    )
    {
        return builder.dataSource(dataSource).packages("com.example.rest.rec.domain").persistenceUnit("resystem").build();
        }

        @Primary
        @Bean(name = "trasactionManager")
        public PlatformTransactionManager transactionManager(
            @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory)
        {
        return new JpaTransactionManager(entityManagerFactory);
        }

}
</code>```

RidDbConfig

```<code>package com.example.rest;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "ridEntityManagerFactory",
        transactionManagerRef = "ridTransactionManager",
        basePackages = {"com.example.rest.rid.repository.repo"}
)

public class RidDbConfig {
    @Bean(name = "ridDataSource")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "ridEntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean ridEntityManagerFactory(
            EntityManagerFactoryBuilder builder,
             @Qualifier("ridDataSource") DataSource dataSource
    )
    {
        return builder.dataSource(dataSource).packages("com.example.rest.rid.repository.domain").persistenceUnit("rid").build();
    }

    @Bean(name="ridTransactionManager")
    public PlatformTransactionManager ridTransactionManager(
            @Qualifier("ridEntityManagerFactory")EntityManagerFactory ridEntityManagerFactory
            )
    {
        return new JpaTransactionManager(ridEntityManagerFactory);
    }
}
</code>```

EmpRepository1

```<code>package com.example.rest.rid.repository.repo;
import com.example.rest.VO.LogVo;
import com.example.rest.rid.repository.domain.R1pro;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmpRepository1 extends JpaRepository<LogVo, Integer> {

    @Query(value = "select * from dt.log order by put_date DESC limit 1",nativeQuery = true)
    public List<R1pro> findByLimit();
}
</code>```

R1pro

```<code>package com.example.rest.rid.repository.domain;

public interface R1pro {
    String getSENT_TOTAL();
}
</code>```

EmpRepository2

```<code>package com.example.rest.rec.repo;
import com.example.rest.VO.Dve;
import com.example.rest.rec.domain.R2pro;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmpRepository2 extends JpaRepository<Dve, String> {

    @Query(value = "SELECT user_id FROM MART limit 1",nativeQuery = true)
    public List<R2pro> findByLimit1();
}
</code>```

R2pro

```<code>package com.example.rest.rec.domain;

public interface R2pro {
    String getUSER_ID();
}
</code>```

EmpController1

```<code>package com.example.rest.controller;

import com.example.rest.rec.repo.EmpRepository2;
import com.example.rest.rid.repository.domain.R1pro;
import com.example.rest.rec.domain.R2pro;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.example.rest.rid.repository.repo.EmpRepository1;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/emp")

public class EmpController1 {
    @Autowired
    private EmpRepository1 empRepository1;
    private EmpRepository2 empRepository2;

    @Autowired
public EmpController1(EmpRepository1 empRepository, EmpRepository2 empRepository2) {
    this.empRepository1 = empRepository1;
    this.empRepository2 = empRepository2;
}

    @RequestMapping(value="/ee", method = RequestMethod.GET)
    @ResponseBody
    public String getCategoryList() {
        R1pro r1pro = empRepository1.findByLimit();

        return r1pro.getSENT_TOTAL();
    }

    @Autowired
    @RequestMapping(value = "/ef",method = RequestMethod.GET)
    @ResponseBody
    public String getgiem(){
        R2pro r2pro =empRepository2.findByLimit1();

        return r2pro.getUSER_ID();
    }
}
</code>```

Application

```<code>package com.example.rest;
import com.example.rest.rid.repository.repo.EmpRepository1;
import com.example.rest.rec.repo.EmpRepository2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
</code>```

So when i run the code i got the this error

```<code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empController1' defined in file [C:\Users\DS-18-D3-023\Desktop\data-migration-new-indicator\springboottutorial\target\classes\com\example\rest\controller\EmpController1.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository2': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.Dve
</code>```

What is wrong..it please teach me

Also the all of the VO is correct columns
when i run the code separate is working very well

all error

```<code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empController1' defined in file [C:\Users\DS-18-D3-023\Desktop\data-migration-new-indicator\springboottutorial\target\classes\com\example\rest\controller\EmpController1.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository1': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1276) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1133) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at com.example.rest.Application.main(Application.java:12) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.3.RELEASE.jar:2.0.3.RELEASE] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository1': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 24 common frames omitted Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:181) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:119) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:102) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:298) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$3(RepositoryFactoryBeanSupport.java:287) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:141) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.util.Lazy.get(Lazy.java:63) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:290) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:102) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 35 common frames omitted

Process finished with exit code 0
</code>```

答:
Try this

```<code>@Repository
public interface EmpRepository1 extends JpaRepository<LogVo, String> {

@Query(value = "select * from dt.log order by put_date DESC limit 1",nativeQuery = true)
public List<R1pro> findByLimit();
}
</code>```

In EmpRepository1.java change JpaRepository to JpaRepository as id in Entity of type String

Body:
i want to get the result which are got two different DB using spring-boot but i got the error now Actually i can't find what is wrong..

VO.Dve code

package com.example.rest.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Table(name = "MART")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Dve {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String USER_ID;
    private Integer ID;

    public String getID() {
        return ID;
    }
}

VO.LogVo

package com.example.rest.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;

@Entity
@Table(name = "log")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LogVo {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String put_date;
    private Integer SCNT;
    private Integer SENT_TOTAL;
    private Integer SCART;
    private Integer ST_TOTAL;
    private Integer Imby_tables_cnt;
    private Integer Alarm;
    private Integer Alert;
    private Integer Watch;
    private Integer TZ;
    private Integer Normal;
    private Integer Rating_sum;

    public Integer getSENT_TOTAL(){
        return SENT_TOTAL;
    }
}

RestDbConfig

package com.example.rest;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

@Configuration
@EnableTransactionManagement

@EnableJpaRepositories(
        entityManagerFactoryRef = "entityManagerFactory",
        basePackages = {"com.example.rest.rec.repo"}
)

public class RestDbConfig {

    @Primary
    @Bean(name = "dataSource")
    @ConfigurationProperties(prefix = "db1.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }

    @Primary
    @Bean(name = "entityManagerFactory")
    public LocalContainerEntityManagerFactoryBean
    entityManagerFactory(
            EntityManagerFactoryBuilder builder,
            @Qualifier("dataSource") DataSource dataSource
    )
    {
        return builder.dataSource(dataSource).packages("com.example.rest.rec.domain").persistenceUnit("resystem").build();
        }

        @Primary
        @Bean(name = "trasactionManager")
        public PlatformTransactionManager transactionManager(
            @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory)
        {
        return new JpaTransactionManager(entityManagerFactory);
        }

}

RidDbConfig

package com.example.rest;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "ridEntityManagerFactory",
        transactionManagerRef = "ridTransactionManager",
        basePackages = {"com.example.rest.rid.repository.repo"}
)

public class RidDbConfig {
    @Bean(name = "ridDataSource")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "ridEntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean ridEntityManagerFactory(
            EntityManagerFactoryBuilder builder,
             @Qualifier("ridDataSource") DataSource dataSource
    )
    {
        return builder.dataSource(dataSource).packages("com.example.rest.rid.repository.domain").persistenceUnit("rid").build();
    }

    @Bean(name="ridTransactionManager")
    public PlatformTransactionManager ridTransactionManager(
            @Qualifier("ridEntityManagerFactory")EntityManagerFactory ridEntityManagerFactory
            )
    {
        return new JpaTransactionManager(ridEntityManagerFactory);
    }
}

EmpRepository1

package com.example.rest.rid.repository.repo;
import com.example.rest.VO.LogVo;
import com.example.rest.rid.repository.domain.R1pro;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmpRepository1 extends JpaRepository<LogVo, Integer> {

    @Query(value = "select * from dt.log order by put_date DESC limit 1",nativeQuery = true)
    public List<R1pro> findByLimit();
}

R1pro

package com.example.rest.rid.repository.domain;

public interface R1pro {
    String getSENT_TOTAL();
}

EmpRepository2

package com.example.rest.rec.repo;
import com.example.rest.VO.Dve;
import com.example.rest.rec.domain.R2pro;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmpRepository2 extends JpaRepository<Dve, String> {

    @Query(value = "SELECT user_id FROM MART limit 1",nativeQuery = true)
    public List<R2pro> findByLimit1();
}

R2pro

package com.example.rest.rec.domain;

public interface R2pro {
    String getUSER_ID();
}

EmpController1

package com.example.rest.controller;

import com.example.rest.rec.repo.EmpRepository2;
import com.example.rest.rid.repository.domain.R1pro;
import com.example.rest.rec.domain.R2pro;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.example.rest.rid.repository.repo.EmpRepository1;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/emp")

public class EmpController1 {
    @Autowired
    private EmpRepository1 empRepository1;
    private EmpRepository2 empRepository2;

    @Autowired
public EmpController1(EmpRepository1 empRepository, EmpRepository2 empRepository2) {
    this.empRepository1 = empRepository1;
    this.empRepository2 = empRepository2;
}

    @RequestMapping(value="/ee", method = RequestMethod.GET)
    @ResponseBody
    public String getCategoryList() {
        R1pro r1pro = empRepository1.findByLimit();

        return r1pro.getSENT_TOTAL();
    }

    @Autowired
    @RequestMapping(value = "/ef",method = RequestMethod.GET)
    @ResponseBody
    public String getgiem(){
        R2pro r2pro =empRepository2.findByLimit1();

        return r2pro.getUSER_ID();
    }
}

Application

package com.example.rest;
import com.example.rest.rid.repository.repo.EmpRepository1;
import com.example.rest.rec.repo.EmpRepository2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

So when i run the code i got the this error

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empController1' defined in file [C:\Users\DS-18-D3-023\Desktop\data-migration-new-indicator\springboottutorial\target\classes\com\example\rest\controller\EmpController1.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository2': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.Dve

What is wrong..it please teach me

Also the all of the VO is correct columns
when i run the code separate is working very well

all error

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empController1' defined in file [C:\Users\DS-18-D3-023\Desktop\data-migration-new-indicator\springboottutorial\target\classes\com\example\rest\controller\EmpController1.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository1': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1276) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1133) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at com.example.rest.Application.main(Application.java:12) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.3.RELEASE.jar:2.0.3.RELEASE] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empRepository1': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 24 common frames omitted Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.rest.VO.LogVo
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:181) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:119) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:102) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:298) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$3(RepositoryFactoryBeanSupport.java:287) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:141) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.util.Lazy.get(Lazy.java:63) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:290) ~[spring-data-commons-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:102) ~[spring-data-jpa-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 35 common frames omitted

Process finished with exit code 0

Body:
Try this

@Repository
public interface EmpRepository1 extends JpaRepository<LogVo, String> {

@Query(value = "select * from dt.log order by put_date DESC limit 1",nativeQuery = true)
public List<R1pro> findByLimit();
}

In EmpRepository1.java change JpaRepository to JpaRepository as id in Entity of type String


来源: stackexchange

问:
loop get vs mget, Is there any performance difference in redis lua?
Given a single instance redis which supports lua scripts. Is there any performance difference between calling 'mget' once and calling 'get' multiple times to retrieve the value of multiple keys?</p>

答:
It will be different in some cases.

MGET key [key ...] Time complexity: O(N) where N is the number of keys to retrieve.

GET key Time complexity: O(1)

According to time complexity, GET is more efficient.

However, there is a difference between passing a single command to redis and passing it multiple times.

If you don't use pool, the difference is even greater.

Of course, what I would recommend is to use it depending on the type of data you want to deal with.

You decide whether it's more efficient to manage your data in Maps.

ContentLicense: CC BY-SA 4.0


问:
How do I convert this list into a data frame where each row is a single entity
I have this data set running into the '00,000 of rows, only 3 is shown here for brevity.

```<code>listy<-    list(ABR = list(ABN = list(text = "11000000948", .attrs = c(status = "ACT",
    ABNStatusFromDate = "19991101")), EntityType = list(EntityTypeInd = "PUB",
        EntityTypeText = "Australian Public Company"), MainEntity = list(
        NonIndividualName = list(NonIndividualNameText = "QBE INSURANCE (INTERNATIONAL) LTD",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2000"))), ASICNumber = list(
        text = "000000948", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "ACT", GSTStatusFromDate = "20000701"),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "QBE INSURANCE (INTERNATIONAL) LIMITED",
            .attrs = c(type = "TRD"))), .attrs = c(recordLastUpdatedDate = "20180216",
        replaced = "N")), ABR = list(ABN = list(text = "11000002568",
        .attrs = c(status = "CAN", ABNStatusFromDate = "20190501"
        )), EntityType = list(EntityTypeInd = "PRV", EntityTypeText = "Australian Private Company"),
        MainEntity = list(NonIndividualName = list(NonIndividualNameText = "TOOHEYS PTY LIMITED",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2141"))), ASICNumber = list(
            text = "000002568", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "CAN", GSTStatusFromDate = "20190502"),
        .attrs = c(recordLastUpdatedDate = "20190531", replaced = "N"
        )), ABR = list(ABN = list(text = "11000016722", .attrs = c(status = "ACT",
    ABNStatusFromDate = "20000303")), EntityType = list(EntityTypeInd = "PUB",
        EntityTypeText = "Australian Public Company"), MainEntity = list(
        NonIndividualName = list(NonIndividualNameText = "INSURANCE AUSTRALIA LIMITED",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2000"))), ASICNumber = list(
        text = "000016722", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "ACT", GSTStatusFromDate = "20000701"),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE LTD",
            .attrs = c(type = "TRD"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE LTD-WORKERS COMPENSATION",
            .attrs = c(type = "OTN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "\"\"Wesfarmers Federation Insurance\"\"",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Aim Dealer Services", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Aim Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Airport Buddy", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Assureme",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Australian Union Assurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Bitsy Cover", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "BuddyCover",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "C G U Professional Risks Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Trade Credit Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Travel Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Advantage",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Cyber Defence", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Home Warranty Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Professional Risks Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU SAFETY AND RISK SERVICES",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU SELF INSURANCE SERVICES",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Trade Credit Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Travel Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Workers Compensation",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Dairypol", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Grain Farmers Crop Insurance Agency",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Grainpol", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "IAG Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "IAG Re Australia", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "IAL.com.au",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Insurance 4 That", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Insurance for That",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "InsureLite", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Kwikinsure",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lioncare", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Connect",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley General", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley General Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Marine & Logistics",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Online", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Retail Warranty",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Special Vehicles", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Metrorider",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "mobility.ai.", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "MOTOR TRADE DIRECT",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Motorassist", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Mums & Company",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "My.Place@Lumley", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA HOME SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NZI Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Pacific Indemnity", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Poncho Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Pounce Pet Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Prestige Boat Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Prestige Car Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Prestige Home Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Quick Insure", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Safer Journeys",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGI Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGI.com.au",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIC", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIC HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIC INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIC SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIO", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIO HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIO INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIO SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Sharecover Enterprises", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Swann Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "THE BUZZ INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "THE BUZZ INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "THE BUZZ INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "THE BUZZ INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "The United Insurance Co", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "The United Insurance Company",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "VACC Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "VACC Rural Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Warrante-Link Warranty Solutions",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Warrantyassist", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Wesfarmers Federation Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "WFI", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "'WFI'",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Yourinsurancegroup", .attrs = c(type = "BN"))),
        .attrs = c(recordLastUpdatedDate = "20190612", replaced = "N"
        )))

xmldf <- data.table::rbindlist(listy, fill = TRUE)
</code>```

I am trying to convert this into a data frame where each row maps into a list element. In this case there should be 3 (rows). It looks like the ABR$ABN$.attrs (and in some cases ABR$GST$.attrs) is forcing the data frame into 2 rows after running this function on the list data.table::rbindlist(list, fill = TRUE). See the picture for an table showing errorexample:

How can I "flatten"? the two rows into 1?

Edit1: Added a bit more code in the example to facilitate a simple cut paste and run in your R instance

答:
You can try this:

```<code>nlist <- lapply(listy,function(x) as.list(unlist(x)))
xmldf <- data.table::rbindlist(nlist, fill = TRUE)
</code>```

The unlist will "flatten" the structure and as.list will allow it to be treated as a 1 row dataframe.

I got a data.table with 3 rows and 203 columns. First few columns look like this:

```<code>      ABN.text ABN..attrs.status ABN..attrs.ABNStatusFromDate EntityType.EntityTypeInd
1: 11000000948               ACT                     19991101                      PUB
2: 11000002568               CAN                     20190501                      PRV
3: 11000016722               ACT                     20000303                      PUB
</code>```

Body:
I have this data set running into the '00,000 of rows, only 3 is shown here for brevity.

listy<-    list(ABR = list(ABN = list(text = "11000000948", .attrs = c(status = "ACT",
    ABNStatusFromDate = "19991101")), EntityType = list(EntityTypeInd = "PUB",
        EntityTypeText = "Australian Public Company"), MainEntity = list(
        NonIndividualName = list(NonIndividualNameText = "QBE INSURANCE (INTERNATIONAL) LTD",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2000"))), ASICNumber = list(
        text = "000000948", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "ACT", GSTStatusFromDate = "20000701"),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "QBE INSURANCE (INTERNATIONAL) LIMITED",
            .attrs = c(type = "TRD"))), .attrs = c(recordLastUpdatedDate = "20180216",
        replaced = "N")), ABR = list(ABN = list(text = "11000002568",
        .attrs = c(status = "CAN", ABNStatusFromDate = "20190501"
        )), EntityType = list(EntityTypeInd = "PRV", EntityTypeText = "Australian Private Company"),
        MainEntity = list(NonIndividualName = list(NonIndividualNameText = "TOOHEYS PTY LIMITED",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2141"))), ASICNumber = list(
            text = "000002568", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "CAN", GSTStatusFromDate = "20190502"),
        .attrs = c(recordLastUpdatedDate = "20190531", replaced = "N"
        )), ABR = list(ABN = list(text = "11000016722", .attrs = c(status = "ACT",
    ABNStatusFromDate = "20000303")), EntityType = list(EntityTypeInd = "PUB",
        EntityTypeText = "Australian Public Company"), MainEntity = list(
        NonIndividualName = list(NonIndividualNameText = "INSURANCE AUSTRALIA LIMITED",
            .attrs = c(type = "MN")), BusinessAddress = list(AddressDetails = list(
            State = "NSW", Postcode = "2000"))), ASICNumber = list(
        text = "000016722", .attrs = c(ASICNumberType = "undetermined")),
        GST = c(status = "ACT", GSTStatusFromDate = "20000701"),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE LTD",
            .attrs = c(type = "TRD"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE LTD-WORKERS COMPENSATION",
            .attrs = c(type = "OTN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "\"\"Wesfarmers Federation Insurance\"\"",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Aim Dealer Services", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Aim Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Airport Buddy", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Assureme",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Australian Union Assurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Bitsy Cover", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "BuddyCover",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "C G U Professional Risks Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Trade Credit Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "C G U Travel Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Advantage",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Cyber Defence", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Home Warranty Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Professional Risks Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU SAFETY AND RISK SERVICES",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU SELF INSURANCE SERVICES",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Trade Credit Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "CGU Travel Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "CGU Workers Compensation",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Dairypol", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Grain Farmers Crop Insurance Agency",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Grainpol", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "IAG Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "IAG Re Australia", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "IAL.com.au",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Insurance 4 That", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Insurance for That",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "InsureLite", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Kwikinsure",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lioncare", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Connect",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley General", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley General Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Marine & Logistics",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Online", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Lumley Retail Warranty",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Lumley Special Vehicles", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Metrorider",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "mobility.ai.", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "MOTOR TRADE DIRECT",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Motorassist", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Mums & Company",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "My.Place@Lumley", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA HOME SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NRMA SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "NRMA SECURITY", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "NZI Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Pacific Indemnity", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Poncho Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Pounce Pet Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Prestige Boat Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Prestige Car Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Prestige Home Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Quick Insure", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Safer Journeys",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGI Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGI.com.au",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIC", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIC HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIC INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIC SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIO", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIO HOME SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "SGIO INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "SGIO SECURITY",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Sharecover Enterprises", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Swann Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "THE BUZZ INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "THE BUZZ INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "THE BUZZ INSURANCE", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "THE BUZZ INSURANCE",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "The United Insurance Co", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "The United Insurance Company",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "VACC Insurance", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "VACC Rural Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Warrante-Link Warranty Solutions",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Warrantyassist", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "Wesfarmers Federation Insurance",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "WFI", .attrs = c(type = "BN"))),
        OtherEntity = list(NonIndividualName = list(NonIndividualNameText = "'WFI'",
            .attrs = c(type = "BN"))), OtherEntity = list(NonIndividualName = list(
            NonIndividualNameText = "Yourinsurancegroup", .attrs = c(type = "BN"))),
        .attrs = c(recordLastUpdatedDate = "20190612", replaced = "N"
        )))

xmldf <- data.table::rbindlist(listy, fill = TRUE)

I am trying to convert this into a data frame where each row maps into a list element. In this case there should be 3 (rows). It looks like the ABR$ABN$.attrs (and in some cases ABR$GST$.attrs) is forcing the data frame into 2 rows after running this function on the list data.table::rbindlist(list, fill = TRUE). See the picture for an table showing errorexample:

How can I "flatten"? the two rows into 1?

Edit1: Added a bit more code in the example to facilitate a simple cut paste and run in your R instance

Body:
You can try this:

nlist <- lapply(listy,function(x) as.list(unlist(x)))
xmldf <- data.table::rbindlist(nlist, fill = TRUE)

The unlist will "flatten" the structure and as.list will allow it to be treated as a 1 row dataframe.

I got a data.table with 3 rows and 203 columns. First few columns look like this:

      ABN.text ABN..attrs.status ABN..attrs.ABNStatusFromDate EntityType.EntityTypeInd
1: 11000000948               ACT                     19991101                      PUB
2: 11000002568               CAN                     20190501                      PRV
3: 11000016722               ACT                     20000303                      PUB


问:
Spring + Google Datastore: @Reference is not persisted
I'm using org.springframework.cloud:spring-cloud-gcp-starter-data-datastore with Kotlin.

The code look like this:

```<code>@Entity(name = "books")
data class Book(
    @Reference val writer: Writer,
    var name: String,
    @Id val id: Key? = null, //I leave the key as NULL so it that can be autogenerated
)

@Entity(name = "writers")
data class Writer(
    var name: String,
    @Id val id: Key? = null
)

//Also with Repositories
</code>```

When I save a Book entity, with a reference to a saved Writer, when I retrieve it, it should be retrieved automatically right?

Sample code:

```<code>var w = Writer("Shakespeare")
w = writerRepo.save(w)
var book = Book(w, "Macbeth")
book = bookRepo.save(book)

books = bookRepo.findByWriter(w) //Error happen here
</code>```

The code above will throw error failed to instantiate Book with NULL Writer. Any idea why this happen?

答:
I find the answer is not because the relationship is not persisted but because The Repository set the relationship Entity after instantiation. The Repository tries to instantiate the Entity first, assign NULL on relationship (annotated with @References) attribute.

Therefore, the Entity should be like this:

```<code>@Entity(name = "books")
data class Book(
    @Reference var writer: Writer?, //Accepting NULL values
    var name: String,
    @Id val id: Key? = null
)
</code>```

And all works well.

Body:
I'm using org.springframework.cloud:spring-cloud-gcp-starter-data-datastore with Kotlin.

The code look like this:

@Entity(name = "books")
data class Book(
    @Reference val writer: Writer,
    var name: String,
    @Id val id: Key? = null, //I leave the key as NULL so it that can be autogenerated
)

@Entity(name = "writers")
data class Writer(
    var name: String,
    @Id val id: Key? = null
)

//Also with Repositories

When I save a Book entity, with a reference to a saved Writer, when I retrieve it, it should be retrieved automatically right?

Sample code:

var w = Writer("Shakespeare")
w = writerRepo.save(w)
var book = Book(w, "Macbeth")
book = bookRepo.save(book)

books = bookRepo.findByWriter(w) //Error happen here

The code above will throw error failed to instantiate Book with NULL Writer. Any idea why this happen?

Body:
I find the answer is not because the relationship is not persisted but because The Repository set the relationship Entity after instantiation. The Repository tries to instantiate the Entity first, assign NULL on relationship (annotated with @References) attribute.

Therefore, the Entity should be like this:

@Entity(name = "books")
data class Book(
    @Reference var writer: Writer?, //Accepting NULL values
    var name: String,
    @Id val id: Key? = null
)

And all works well.


问:
C# Prevent a started app from writing in the console
I have an app which starts another app. This other app prints a few lines into the Console but noone needs this output and it prints it's output betwenn my own. How can I prevent this other app from printing it's stuff into my console?
I tried to run with ProcessStartInfo.UseShellExecutive both on true and false, also tried to change the console output into a MemoryStream before starting but since I need the Console i had to change the output back and it looks like the other app got their input changed back too.

```<code>Process serverprocess = new Process();
serverprocess.StartInfo.FileName = Path.GetFileName(serverpath);
serverprocess.StartInfo.Arguments = launch;
serverprocess.StartInfo.UseShellExecute = false;
serverprocess.StartInfo.RedirectStandardOutput = true;
serverprocess.Start();
</code>```

答:
In your code ensure that you are re-directing both StandardOutput and StandardError that way everything that the "ThirdPartyApp" writes will be captured in either of these streams.

I have written a small Helper Class that helps with this

You can use like

```<code>//Launching excel.exe with /safe as arg
var excelExample1 = @"""C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE"" /safe";

LaunchCMD.Invoke(excelExample1);

//To get its output, if any
var getOutput = LaunchCMD.Output;
</code>```

LaunchCMD Helper Class

```<code>class LaunchCMD
{

    public static string Output
    {
        get; set;
    } = "";

    public static void Invoke(string command, bool waitTillExit = false, bool closeOutputWindow = false)
    {

        ProcessStartInfo ProcessInfo;
        Process Process = new Process();

        ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + command);

        ProcessInfo.CreateNoWindow = false;
        ProcessInfo.UseShellExecute = false;
        ProcessInfo.RedirectStandardOutput = true;
        ProcessInfo.RedirectStandardError = true;
        Process.EnableRaisingEvents = true;

        Process = Process.Start(ProcessInfo);

        Process.ErrorDataReceived += ConsoleDataReceived;
        Process.OutputDataReceived += ConsoleDataReceived;

        Process.BeginOutputReadLine();
        Process.BeginErrorReadLine();

        if (waitTillExit == true)
        {

            Process.WaitForExit();
        }
        if (closeOutputWindow == true)
        {
            Process.CloseMainWindow();
        }

        Process.Close();
        System.Threading.Thread.Sleep(1000);
        Output.ToString();

    }

    private static void ConsoleDataReceived(object sender, DataReceivedEventArgs e)
    {
        System.Threading.Thread.Sleep(1000);
        if (e.Data != null)
        {
            Output = Output + e.Data;
        }
    }

}
</code>```

Body:
I have an app which starts another app. This other app prints a few lines into the Console but noone needs this output and it prints it's output betwenn my own. How can I prevent this other app from printing it's stuff into my console?
I tried to run with ProcessStartInfo.UseShellExecutive both on true and false, also tried to change the console output into a MemoryStream before starting but since I need the Console i had to change the output back and it looks like the other app got their input changed back too.

Process serverprocess = new Process();
serverprocess.StartInfo.FileName = Path.GetFileName(serverpath);
serverprocess.StartInfo.Arguments = launch;
serverprocess.StartInfo.UseShellExecute = false;
serverprocess.StartInfo.RedirectStandardOutput = true;
serverprocess.Start();

Body:
In your code ensure that you are re-directing both StandardOutput and StandardError that way everything that the "ThirdPartyApp" writes will be captured in either of these streams.

I have written a small Helper Class that helps with this

You can use like

//Launching excel.exe with /safe as arg
var excelExample1 = @"""C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE"" /safe";

LaunchCMD.Invoke(excelExample1);

//To get its output, if any
var getOutput = LaunchCMD.Output;

LaunchCMD Helper Class

class LaunchCMD
{

    public static string Output
    {
        get; set;
    } = "";

    public static void Invoke(string command, bool waitTillExit = false, bool closeOutputWindow = false)
    {

        ProcessStartInfo ProcessInfo;
        Process Process = new Process();

        ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + command);

        ProcessInfo.CreateNoWindow = false;
        ProcessInfo.UseShellExecute = false;
        ProcessInfo.RedirectStandardOutput = true;
        ProcessInfo.RedirectStandardError = true;
        Process.EnableRaisingEvents = true;

        Process = Process.Start(ProcessInfo);

        Process.ErrorDataReceived += ConsoleDataReceived;
        Process.OutputDataReceived += ConsoleDataReceived;

        Process.BeginOutputReadLine();
        Process.BeginErrorReadLine();

        if (waitTillExit == true)
        {

            Process.WaitForExit();
        }
        if (closeOutputWindow == true)
        {
            Process.CloseMainWindow();
        }

        Process.Close();
        System.Threading.Thread.Sleep(1000);
        Output.ToString();

    }

    private static void ConsoleDataReceived(object sender, DataReceivedEventArgs e)
    {
        System.Threading.Thread.Sleep(1000);
        if (e.Data != null)
        {
            Output = Output + e.Data;
        }
    }

}


问:
SQL "like" statement: 'Jeff' LIKE 'Jeff' = false?
EDIT: Problem solved. It was my reading that was incorrect, not the SQL :p

Hi!

I was just reading in my database book about the LIKE SQL statement. It said this:

```<code>SELECT whatever FROM whereever WHERE 'Jeff' LIKE 'Jeff';
</code>```

It continued to say that the statement 'Jeff' LIKE 'Jeff' would always return false. The book did not tell me why, nor can I find this anywhere else. Does this then mean that the following SQL also would return null?

```<code>SELECT W.name FROM whereever W WHERE w.name LIKE 'Jeff';
</code>```

For reference, the book is:
Database Management Systems: Ramakrishnan - Gehrke From McGRAW - Hill. International edition. ISBN 0-07-123151-X PAGE 140.

答:
That section of the book deals with blanks.  They are saying that, in sql,

'Jeff' = 'Jeff ' (note the extra space) results in TRUE but

'Jeff' LIKE 'Jeff ' (again, with the extra space) results in FALSE

Hope that clears things up.

ContentLicense: CC BY-SA 3.0

Body:
EDIT: Problem solved. It was my reading that was incorrect, not the SQL :p

Hi!

I was just reading in my database book about the LIKE SQL statement. It said this:

SELECT whatever FROM whereever WHERE 'Jeff' LIKE 'Jeff';

It continued to say that the statement 'Jeff' LIKE 'Jeff' would always return false. The book did not tell me why, nor can I find this anywhere else. Does this then mean that the following SQL also would return null?

SELECT W.name FROM whereever W WHERE w.name LIKE 'Jeff';

For reference, the book is:
Database Management Systems: Ramakrishnan - Gehrke From McGRAW - Hill. International edition. ISBN 0-07-123151-X PAGE 140.


问:
Is it possible to declare that a Supplier<T> needs to throw an Exception?
So I am trying to refactor the following code:

```<code>/**
 * Returns the duration from the config file.
 *
 * @return  The duration.
 */
private Duration durationFromConfig() {
    try {
        return durationFromConfigInner();
    } catch (IOException ex) {
        throw new IllegalStateException("The config file (\"" + configFile + "\") has not been found.");
    }
}

/**
 * Returns the duration from the config file.
 *
 * Searches the log file for the first line indicating the config entry for this instance.
 *
 * @return  The duration.
 * @throws FileNotFoundException If the config file has not been found.
 */
private Duration durationFromConfigInner() throws IOException {
    String entryKey = subClass.getSimpleName();
    configLastModified = Files.getLastModifiedTime(configFile);
    String entryValue = ConfigFileUtils.readFileEntry(configFile, entryKey);
    return Duration.of(entryValue);
}
</code>```

I came up with the following to start of with:

```<code>private <T> T getFromConfig(final Supplier<T> supplier) {
    try {
        return supplier.get();
    } catch (IOException ex) {
        throw new IllegalStateException("The config file (\"" + configFile + "\") has not been found.");
    }
}
</code>```

However, it does not compile (obviously), as Supplier cannot throw an IOException. Is there any way I can add that to the method declaration of getFromConfig?

Or is the only way to do it like the following?

```<code>@FunctionalInterface
public interface SupplierWithIO<T> extends Supplier<T> {
    @Override
    @Deprecated
    default public T get() {
        throw new UnsupportedOperationException();
    }

    public T getWithIO() throws IOException;
}
</code>```

Update, I just realised that the Supplier interface is a really simple one, as in it has only the get() method. The original reason why I extended Supplier is to preverse the basic functionality, like the default methods for example.

答:
We can use this generic solution also. Any type of exception we handle by this approach.</p>

```<code>    @FunctionalInterface
    public interface CheckedCall<T, E extends Throwable> {
        T call() throws E;
    }

    public <T> T logTime(CheckedCall<T, Exception> block) throws Exception {

        Stopwatch timer = Stopwatch.createStarted();
        try {
            T result = block.call();
            System.out.println(timer.stop().elapsed(TimeUnit.MILLISECONDS));
            return result;
        } catch (Exception e) {
            throw e;
        }
    }

</code>```

Body:
So I am trying to refactor the following code:

/**
 * Returns the duration from the config file.
 *
 * @return  The duration.
 */
private Duration durationFromConfig() {
    try {
        return durationFromConfigInner();
    } catch (IOException ex) {
        throw new IllegalStateException("The config file (\"" + configFile + "\") has not been found.");
    }
}

/**
 * Returns the duration from the config file.
 *
 * Searches the log file for the first line indicating the config entry for this instance.
 *
 * @return  The duration.
 * @throws FileNotFoundException If the config file has not been found.
 */
private Duration durationFromConfigInner() throws IOException {
    String entryKey = subClass.getSimpleName();
    configLastModified = Files.getLastModifiedTime(configFile);
    String entryValue = ConfigFileUtils.readFileEntry(configFile, entryKey);
    return Duration.of(entryValue);
}

I came up with the following to start of with:

private <T> T getFromConfig(final Supplier<T> supplier) {
    try {
        return supplier.get();
    } catch (IOException ex) {
        throw new IllegalStateException("The config file (\"" + configFile + "\") has not been found.");
    }
}

However, it does not compile (obviously), as Supplier cannot throw an IOException. Is there any way I can add that to the method declaration of getFromConfig?

Or is the only way to do it like the following?

@FunctionalInterface
public interface SupplierWithIO<T> extends Supplier<T> {
    @Override
    @Deprecated
    default public T get() {
        throw new UnsupportedOperationException();
    }

    public T getWithIO() throws IOException;
}

Update, I just realised that the Supplier interface is a really simple one, as in it has only the get() method. The original reason why I extended Supplier is to preverse the basic functionality, like the default methods for example.

Body:
We can use this generic solution also. Any type of exception we handle by this approach.

    @FunctionalInterface
    public interface CheckedCall<T, E extends Throwable> {
        T call() throws E;
    }

    public <T> T logTime(CheckedCall<T, Exception> block) throws Exception {

        Stopwatch timer = Stopwatch.createStarted();
        try {
            T result = block.call();
            System.out.println(timer.stop().elapsed(TimeUnit.MILLISECONDS));
            return result;
        } catch (Exception e) {
            throw e;
        }
    }


问:
"Cannot Preview in this file - Failed to launch [App Name]"
I am trying to play around with swiftUI in Xcode 11 and macOS Catalina.
BUT
After creating a new Project, there is a boiler plate code with a Text that says hello World. I want to have a live preview of this simple welcome message in the canvas by the side of the code.

When i hit the resume button :
It says :

Cannot Preview in this file - Failed to launch [App Name]

I've tried hitting the diagnostic button that generated a report to send it to APPLE saying:

[FailedToLaunchError(url:
  file:///Users/naive/Library/Developer/Xcode/DerivedData/first_swiftUI-dymizjogcbtouhclgjhhefagmcqo/Build/Intermediates.noindex/Previews/first_swiftUI/Products/Debug-iphoneos/first_swiftUI.app,
  underlying: Error Domain=NSOSStatusErrorDomain Code=-10661 "(null)"
  UserInfo={_LSLine=3554, _LSFunction=_LSOpenStuffCallLocal},
  failureCategory: UVFoundation.FailureCategory.infrastructureFailure) ]

Here's the code, It is the default code that comes with new project created with Xcode 11 and SwiftUI option checked:

```<code>import SwiftUI

struct ContentView : View {
    var body: some View {
        Text("Hello World")
    }
}

#if DEBUG
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif
</code>```

I expect the canvas to show up and display live preview of my code.
The canvas is not showing up !!

There are two warning messages generated :

:0: warning: imported declaration
  'UITableViewDiffableDataSourceCellProvider' could not be mapped to
  'UITableViewDiffableDataSourceReference.CellProvider'

:0: warning: imported declaration
  'UICollectionViewDiffableDataSourceCellProvider' could not be mapped
  to 'UICollectionViewDiffableDataSourceReference.CellProvider'

other than that,
My iPad 11"with iPadOS beta runs the app,
The simulator is working as well

答:
I just quit and reopened Xcode with the same project and the preview started working again.

If that doesn't work try Command + K to clean the project, then tap "Resume" to try again.

Body:
I am trying to play around with swiftUI in Xcode 11 and macOS Catalina.
BUT
After creating a new Project, there is a boiler plate code with a Text that says hello World. I want to have a live preview of this simple welcome message in the canvas by the side of the code.

When i hit the resume button :
It says :

Cannot Preview in this file - Failed to launch [App Name]

I've tried hitting the diagnostic button that generated a report to send it to APPLE saying:

[FailedToLaunchError(url:
  file:///Users/naive/Library/Developer/Xcode/DerivedData/first_swiftUI-dymizjogcbtouhclgjhhefagmcqo/Build/Intermediates.noindex/Previews/first_swiftUI/Products/Debug-iphoneos/first_swiftUI.app,
  underlying: Error Domain=NSOSStatusErrorDomain Code=-10661 "(null)"
  UserInfo={_LSLine=3554, _LSFunction=_LSOpenStuffCallLocal},
  failureCategory: UVFoundation.FailureCategory.infrastructureFailure) ]

Here's the code, It is the default code that comes with new project created with Xcode 11 and SwiftUI option checked:

import SwiftUI

struct ContentView : View {
    var body: some View {
        Text("Hello World")
    }
}

#if DEBUG
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif

I expect the canvas to show up and display live preview of my code.
The canvas is not showing up !!

There are two warning messages generated :

:0: warning: imported declaration
  'UITableViewDiffableDataSourceCellProvider' could not be mapped to
  'UITableViewDiffableDataSourceReference.CellProvider'

:0: warning: imported declaration
  'UICollectionViewDiffableDataSourceCellProvider' could not be mapped
  to 'UICollectionViewDiffableDataSourceReference.CellProvider'

other than that,
My iPad 11"with iPadOS beta runs the app,
The simulator is working as well


问:
How to blur a specific position in the picture using CustomPainter in flutter
Is it possible to add blur effect to picture using painting? If so, how can I do this?

答:
use this :</p>

```<code>Stack(
    children: <Widget>[
      YourImageWidget(),
      new BackdropFilter(
        filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
        child: new Container(
          decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
        ),
      ),

    ],
  )
</code>```

Body:
use this :

Stack(
    children: <Widget>[
      YourImageWidget(),
      new BackdropFilter(
        filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
        child: new Container(
          decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
        ),
      ),

    ],
  )


问:
Updating pandas dataframe with new column
I want to create a new column with all the distinct values across the rows. Each value in a row is a string(not list).

This is how dataframe looks like:

```<code>+-----------------------------+-------------------------+---------------------------------------------+
|         first               |            second       |           third                             |
+-----------------------------+-------------------------+---------------------------------------------+
|['able', 'shovel', 'door']   |['shovel raised']        |['shovel raised', 'raised', 'door', 'shovel']|
|['grade control']            |['grade']                |['grade']                                    |
|['light telling', 'love']    |['would love', 'closed'] |['closed', 'light']                          |
+-----------------------------+-------------------------+---------------------------------------------+
</code>```

This is how the dataframe should look like after creating a new column with distinct values.

df = pd.DataFrame({'first': "['able', 'shovel', 'door']" , 'second': "['shovel raised']", 'third': "['shovel raised', 'raised', 'door', 'shovel']", "Distinct_set": "['able', 'shovel', 'door', 'shovel raised', 'raised']" }, index = [0])```

How can I do it?

答:
try this:

```<code>df['new_col'] = df.apply(lambda x: list(set(x['first'] + x['second']+x['third'])), axis =1)
</code>```

its creating set of single char as your data in cell is string.

"['able', 'shovel', 'door']"

to correct this use below:

```<code>df['new_col'] = df.apply(lambda x: list(set(eval(x['first']) + eval(x['second'])+eval(x['third']))), axis =1)

</code>```

Body:
I want to create a new column with all the distinct values across the rows. Each value in a row is a string(not list).

This is how dataframe looks like:

+-----------------------------+-------------------------+---------------------------------------------+
|         first               |            second       |           third                             |
+-----------------------------+-------------------------+---------------------------------------------+
|['able', 'shovel', 'door']   |['shovel raised']        |['shovel raised', 'raised', 'door', 'shovel']|
|['grade control']            |['grade']                |['grade']                                    |
|['light telling', 'love']    |['would love', 'closed'] |['closed', 'light']                          |
+-----------------------------+-------------------------+---------------------------------------------+

This is how the dataframe should look like after creating a new column with distinct values.

df = pd.DataFrame({'first': "['able', 'shovel', 'door']" , 'second': "['shovel raised']", 'third': "['shovel raised', 'raised', 'door', 'shovel']", "Distinct_set": "['able', 'shovel', 'door', 'shovel raised', 'raised']" }, index = [0])

How can I do it?

Body:
try this:

df['new_col'] = df.apply(lambda x: list(set(x['first'] + x['second']+x['third'])), axis =1)

its creating set of single char as your data in cell is string.

"['able', 'shovel', 'door']"

to correct this use below:

df['new_col'] = df.apply(lambda x: list(set(eval(x['first']) + eval(x['second'])+eval(x['third']))), axis =1)