我有这两个类,ManyToMany它们之间有关联:
苗圃.php
namespace VS\CrmBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Nursery
*
* @ORM\Table(name="Nursery")
* @ORM\Entity(repositoryClass="VS\CrmBundle\Repository\NurseryRepository")
*/
class Nursery
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=100)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="phone_number", type="string", length=15, nullable=true)
*/
private $phoneNumber;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @var \DateTime
* …Run Code Online (Sandbox Code Playgroud) 我有一个Java类
public class A {
private int id;
private BigDecimal amount;
}
Run Code Online (Sandbox Code Playgroud)
我想通过id与java 8分组这样的几个对象:
public class Main {
public static void main(String[] args) {
A a1 = new A(1, new BigDecimal("500.36"));
A a2 = new A(2, new BigDecimal("439.97"));
A a3 = new A(2, new BigDecimal("49.97"));
A a4 = new A(2, new BigDecimal("9.97"));
List<A> postings = new ArrayList<>();
postings.add(a1);
postings.add(a2);
postings.add(a3);
postings.add(a4);
List<A> brol = new ArrayList<>();
System.out.println("-----------------");
postings.stream()
.collect(Collectors.groupingBy(A -> A.getId(), Collectors.summingDouble(A->A.getAmount().doubleValue())))
.forEach((id, sum) -> brol.add(new A(id, BigDecimal.valueOf(sum))));
brol.forEach(System.out::println);
} …Run Code Online (Sandbox Code Playgroud) 我们假设我有一个这样的类:
public class A {
private int id;
private BigDecimal amount;
}
Run Code Online (Sandbox Code Playgroud)
我有一个List<A>.如何A使用Java 8流找到列表中所有对象的最大数量?
这个方法:
List<A> brol = new ArrayList<>();
BigDecimal max = brol.stream().max(Comparator.comparing(A -> A.getAmount())).get().getAmount();
System.out.println("MAX = " + max);
Run Code Online (Sandbox Code Playgroud)
给人NoSuchElementException所以我应该为此创建特定的比较?
您好我正在使用Python中的脚本连接到数据库检索一些信息并发送电子邮件.使用Psycopg进行查询时遇到问题.
我想要检索所有用户created_at = nb_days.我的查询在navicat/pgadmin中非常好用,我查询了53条记录:
select a.account_name, a.email, a.user_id, a.locale, a.firstname from v_accounts a where date(a.created_at) = date(current_date - interval '2 days')
Run Code Online (Sandbox Code Playgroud)
但是当我执行我的脚本时,我有None查询的结果.这是我的脚本class:
import psycopg2
class MyDatabase(object):
db_name='you'
user='will'
pw='never'
host='know'
port='it'
def __init__(self, db=db_name, user=user, password=pw, host=host, port=port):
"""Connection to db - creation of the cursor"""
try:
self.baseDonn = psycopg2.connect(host=host, port=port, database=db, user=user,password=password)
except Exception as err:
print('La connexion avec la base de données à échoué : Erreur détéctée : %s' % err)
else: …Run Code Online (Sandbox Code Playgroud) 我有一个包含多个作业的 jar,我想每次只执行一项作业并检索自定义退出代码。
例如,我有一个基本的作业 ( retrieveErrorsJob) 配置,其中一个步骤将读取输入的 XML 文件并将数据写入特定的数据库表中。
应用类
@SpringBootApplication
@EnableBatchProcessing
@Import(CoreCommonsAppComponent.class)
public class Application {
private static final Logger logger = LoggerFactory.getLogger(Application.class);
private ConfigurationConstants constants;
@Autowired
public Application(ConfigurationConstants constants) {
this.constants = constants;
}
@EventListener(ApplicationStartedEvent.class)
public void idApplication()
{
logger.info("================================================");
logger.info(constants.APPLICATION_NAME() + "-v." + constants.APPLICATION_VERSION() + " started on " + constants.REMOTE_HOST());
logger.info("------------------------------------------------");
}
public static void main(String... args) throws Exception{
ApplicationContext context = SpringApplication.run(Application.class, args);
logger.info("================================================");
SpringApplication.exit(context);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以从命令行选择一项工作:
java -jar my-jar.jar --spring.batch.job.names=retrieveErrorsJob --input.xml.file=myfile.xml
Spring Batch …
java ×3
java-8 ×2
java-stream ×2
bigdecimal ×1
doctrine-orm ×1
exit-code ×1
jvm ×1
orm ×1
php ×1
postgresql ×1
psycopg2 ×1
python ×1
spring ×1
spring-boot ×1
symfony ×1